预构建数据源
⚠️️目前预构建数据源的描述版本为
1.0+alpha-1.1
。
为方便客户端使用仓库数据,元数据仓库中的数据可以单向地构建为 SQLite DB
的形式供客户端读取。
描述文件
预构建数据源需要生成两个文件:repo.json
和 repo.db
。其中 repo.json
被称为描述文件,格式如下:
{
// 仓库上次更新的时间戳,单位为秒
"last_modified": 1642568493
}
仓库元数据(repo_info
)
CREATE TABLE IF NOT EXISTS "repo_info" (
"key" TEXT NOT NULL UNIQUE,
"value" TEXT
);
其中固定的 key
如下:
key | 描述 |
---|---|
repo_name | 仓库名 |
repo_edition | 生成时的元数据仓库的描述版本 |
repo_url | 仓库地址 |
repo_ref | 生成时元数据仓库的 ref |
db_version | 生成时预构建数据源的描述版本 |
专辑(repo_album
)
CREATE TABLE IF NOT EXISTS "repo_album" (
"album_id" BLOB NOT NULL UNIQUE,
"title" TEXT NOT NULL,
"edition" TEXT,
"catalog" TEXT NOT NULL,
"artist" TEXT NOT NULL,
"release_date" TEXT NOT NULL,
"disc_count" INTEGER NOT NULL,
"album_type" TEXT NOT NULL DEFAULT 'normal' CHECK("album_type" IN ('normal', 'instrumental', 'absolute', 'drama', 'radio', 'vocal'))
);
CREATE UNIQUE INDEX "repo_album_index" ON "repo_album" (
"album_id"
);
唱片(repo_disc
)
CREATE TABLE IF NOT EXISTS "repo_disc" (
"album_id" BLOB NOT NULL,
"disc_id" INTEGER NOT NULL,
"title" TEXT NOT NULL,
"artist" TEXT NOT NULL,
"catalog" TEXT NOT NULL,
"track_count" INTEGER NOT NULL,
"disc_type" TEXT NOT NULL DEFAULT 'normal' CHECK("disc_type" IN ('normal', 'instrumental', 'absolute', 'drama', 'radio', 'vocal')),
UNIQUE("album_id","disc_id"),
FOREIGN KEY("album_id") REFERENCES "repo_album"("album_id")
);
CREATE UNIQUE INDEX IF NOT EXISTS "repo_disc_index" ON "repo_disc" (
"album_id",
"disc_id"
);
音轨(repo_track
)
CREATE TABLE IF NOT EXISTS "repo_track" (
"album_id" BLOB NOT NULL,
"disc_id" INTEGER NOT NULL,
"track_id" INTEGER NOT NULL,
"title" TEXT NOT NULL,
"artist" TEXT NOT NULL,
"track_type" TEXT NOT NULL DEFAULT 'normal' CHECK("track_type" IN ('normal', 'instrumental', 'absolute', 'drama', 'radio', 'vocal')),
UNIQUE("album_id","disc_id","track_id"),
FOREIGN KEY("album_id", "disc_id") REFERENCES "repo_disc"("album_id", "disc_id")
);
CREATE UNIQUE INDEX IF NOT EXISTS "repo_track_index" ON "repo_track" (
"album_id",
"disc_id",
"track_id"
);
标签定义(repo_tag
)
CREATE TABLE IF NOT EXISTS "repo_tag" (
"tag_id" INTEGER NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"tag_type" TEXT NOT NULL DEFAULT 'unknown' CHECK("tag_type" IN ('artist', 'group', 'animation', 'radio', 'series', 'project', 'game', 'organization', 'unknown', 'category')),
PRIMARY KEY("tag_id" AUTOINCREMENT),
UNIQUE("name", "tag_type")
);
标签表示(repo_tag_detail
)
CREATE TABLE IF NOT EXISTS "repo_tag_detail" (
"tag_id" INTEGER NOT NULL,
"album_id" BLOB NOT NULL,
"disc_id" INTEGER,
"track_id" INTEGER,
FOREIGN KEY("tag_id") REFERENCES "repo_tag"("tag_id")
);
CREATE INDEX IF NOT EXISTS "repo_tag_detail_index" ON "repo_tag_detail" (
"album_id",
"disc_id",
"track_id"
);
标签本地化名(repo_tag_i18n
)
CREATE TABLE IF NOT EXISTS "repo_tag_i18n" (
"tag_id" INTEGER NOT NULL,
"language" TEXT NOT NULL,
"name" TEXT NOT NULL,
FOREIGN KEY("tag_id") REFERENCES "repo_tag"("tag_id")
);
标签关系(repo_tag_relation
)
CREATE TABLE IF NOT EXISTS "repo_tag_relation" (
"tag_id" INTEGER NOT NULL,
"parent_id" INTEGER NOT NULL,
FOREIGN KEY("tag_id") REFERENCES "repo_tag"("tag_id"),
FOREIGN KEY("parent_id") REFERENCES "repo_tag"("tag_id")
);
补充艺术家(repo_artists
)
CREATE TABLE IF NOT EXISTS "repo_artists" (
"album_id" BLOB NOT NULL,
"disc_id" INTEGER,
"track_id" INTEGER,
"key" TEXT NOT NULL,
"value" TEXT
);