Split migrations into separate files
This commit is contained in:
parent
83e216e401
commit
05856d624c
@ -197,15 +197,15 @@
|
||||
ln -s ${self.packages.${system}.RADKFILE}/* data
|
||||
ln -s ${self.packages.${system}.KANJIDIC2}/* data
|
||||
|
||||
sqlite3 ${dbName} < migrations/0001_initial.sql
|
||||
sqlite3 ${dbName} < migrations/0002_insert_info_values.sql
|
||||
for migration in migrations/*.sql; do
|
||||
sqlite3 ${dbName} < $migration
|
||||
done
|
||||
|
||||
ja_db ${pkgs.sqlite.out}/lib/libsqlite3.so
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp migrations/0001_initial.sql $out/schema.sql
|
||||
cp ${dbName} $out/${dbName}
|
||||
'';
|
||||
};
|
||||
|
@ -1,9 +1,3 @@
|
||||
-- TODO: figure out ondelete functions...
|
||||
|
||||
------------
|
||||
-- JMdict --
|
||||
------------
|
||||
|
||||
CREATE TABLE "JMdict_InfoDialect" (
|
||||
"id" VARCHAR(4) PRIMARY KEY NOT NULL,
|
||||
"description" TEXT NOT NULL
|
||||
@ -253,191 +247,3 @@ CREATE TABLE "JMdict_EntryByEnglish" (
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "JMdict_EntryByEnglish_byEnglish" ON "JMdict_EntryByEnglish"("english");
|
||||
|
||||
--------------
|
||||
-- RADKFILE --
|
||||
--------------
|
||||
|
||||
CREATE TABLE "RADKFILE" (
|
||||
"kanji" CHAR(1) NOT NULL,
|
||||
"radical" CHAR(1) NOT NULL,
|
||||
PRIMARY KEY ("kanji", "radical")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "RADK" ON "RADKFILE"("radical");
|
||||
CREATE INDEX "KRAD" ON "RADKFILE"("kanji");
|
||||
|
||||
CREATE VIEW "RADKFILE_Radicals" AS
|
||||
SELECT DISTINCT "radical" FROM "RADKFILE";
|
||||
|
||||
--------------
|
||||
-- KANJIDIC --
|
||||
--------------
|
||||
|
||||
CREATE TABLE "KANJIDIC_Character" (
|
||||
"literal" CHAR(1) NOT NULL PRIMARY KEY,
|
||||
"grade" INTEGER CHECK ("grade" BETWEEN 1 AND 10),
|
||||
"strokeCount" INTEGER NOT NULL,
|
||||
"frequency" INTEGER,
|
||||
"jlpt" INTEGER
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_RadicalName" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"name" TEXT NOT NULL,
|
||||
PRIMARY KEY("kanji", "name")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_Codepoint" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"type" VARCHAR(6) NOT NULL CHECK ("type" IN ('jis208', 'jis212', 'jis213', 'ucs')),
|
||||
"codepoint" VARCHAR(7) NOT NULL,
|
||||
PRIMARY KEY ("kanji", "type")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Codepoint_byCharacter" ON "KANJIDIC_Codepoint"("kanji");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Radical" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"type" VARCHAR(9) NOT NULL CHECK ("type" IN ('classical', 'nelson_c')),
|
||||
"radical" INTEGER NOT NULL CHECK ("radical" BETWEEN 1 AND IIF("type" = 'classical', 214, 212)),
|
||||
PRIMARY KEY("kanji", "type")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_StrokeMiscount" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"strokeCount" INTEGER NOT NULL,
|
||||
PRIMARY KEY("kanji", "strokeCount")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_Variant" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"variant" TEXT NOT NULL,
|
||||
"type" VARCHAR(8) NOT NULL CHECK (
|
||||
"type" IN (
|
||||
'jis208',
|
||||
'jis212',
|
||||
'jis213',
|
||||
'deroo',
|
||||
'njecd',
|
||||
's_h',
|
||||
'nelson_c',
|
||||
'oneill',
|
||||
'ucs'
|
||||
)
|
||||
),
|
||||
PRIMARY KEY ("kanji", "type", "variant")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "_KANJIDIC_DictionaryReference_Part1" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"ref" VARCHAR(9) NOT NULL,
|
||||
"type" VARCHAR(16) NOT NULL CHECK(
|
||||
"type" IN (
|
||||
'nelson_c',
|
||||
'nelson_n',
|
||||
'halpern_njecd',
|
||||
'halpern_kkd',
|
||||
'halpern_kkld',
|
||||
'halpern_kkld_2ed',
|
||||
'heisig',
|
||||
'heisig6',
|
||||
'gakken',
|
||||
'oneill_names',
|
||||
'oneill_kk',
|
||||
'henshall',
|
||||
'sh_kk',
|
||||
'sh_kk2',
|
||||
'sakade',
|
||||
'jf_cards',
|
||||
'henshall3',
|
||||
'tutt_cards',
|
||||
'crowley',
|
||||
'kanji_in_context',
|
||||
'busy_people',
|
||||
'kodansha_compact',
|
||||
'maniette'
|
||||
)
|
||||
),
|
||||
PRIMARY KEY("kanji", "type")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "_KANJIDIC_DictionaryReference_Moro" (
|
||||
"kanji" CHAR(1) NOT NULL PRIMARY KEY REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"ref" VARCHAR(7) NOT NULL,
|
||||
"volume" INTEGER,
|
||||
"page" INTEGER
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_DictionaryReference_byPart1" ON "_KANJIDIC_DictionaryReference_Part1"("kanji", "ref", "type");
|
||||
CREATE INDEX "KANJIDIC_DictionaryReference_byMoro" ON "_KANJIDIC_DictionaryReference_Moro"("kanji", "ref", "volume", "page");
|
||||
|
||||
CREATE VIEW "KANJIDIC_DictionaryReference" AS
|
||||
SELECT "kanji", "ref", "type", NULL AS "volume", NULL AS "page" FROM "_KANJIDIC_DictionaryReference_Part1"
|
||||
UNION
|
||||
SELECT "kanji", "ref", 'moro' AS "type", "volume", "page" FROM "_KANJIDIC_DictionaryReference_Moro";
|
||||
|
||||
CREATE TABLE "KANJIDIC_QueryCode" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"code" VARCHAR(7) NOT NULL,
|
||||
"type" VARCHAR(11) NOT NULL CHECK ("type" IN ('skip', 'sh_desc', 'four_corner', 'deroo', 'misclass')),
|
||||
"SKIPMisclassification" VARCHAR(15),
|
||||
PRIMARY KEY ("kanji", "type", "code")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_Reading" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"type" VARCHAR(8) NOT NULL CHECK ("type" IN ('korean_h', 'korean_r', 'pinyin')),
|
||||
"reading" TEXT NOT NULL,
|
||||
PRIMARY KEY ("kanji", "type", "reading")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Reading_byReading" ON "KANJIDIC_Reading"("reading");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Kunyomi" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"yomi" TEXT NOT NULL,
|
||||
"isJouyou" BOOLEAN,
|
||||
PRIMARY KEY ("kanji", "yomi")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Kunyomi_byYomi" ON "KANJIDIC_Kunyomi"("yomi");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Onyomi" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"yomi" TEXT NOT NULL,
|
||||
"type" VARCHAR(7) CHECK ("type" IN ('kan', 'go', 'tou', 'kan''you')),
|
||||
"isJouyou" BOOLEAN,
|
||||
PRIMARY KEY ("kanji", "yomi")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Onyomi_byYomi" ON "KANJIDIC_Onyomi"("yomi");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Meaning" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"language" CHAR(3) NOT NULL DEFAULT "eng",
|
||||
"meaning" TEXT NOT NULL,
|
||||
PRIMARY KEY ("kanji", "language", "meaning")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Meaning_byMeaning" ON "KANJIDIC_Meaning"("meaning");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Nanori" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"nanori" TEXT NOT NULL,
|
||||
PRIMARY KEY ("kanji", "nanori")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Nanori_byNanori" ON "KANJIDIC_Nanori"("nanori");
|
||||
|
||||
-------------------------
|
||||
-- Interdict relations --
|
||||
-------------------------
|
||||
|
||||
-- Radk - kanjidic
|
||||
-- kanjireading -> filter kanji regex - kanjidic
|
||||
-- index kanji search by romaji
|
||||
-- index kanji search by hiragana
|
||||
-- index word search by romaji
|
||||
-- index word search by hiragana
|
||||
|
11
migrations/0003_RADKFILE.sql
Normal file
11
migrations/0003_RADKFILE.sql
Normal file
@ -0,0 +1,11 @@
|
||||
CREATE TABLE "RADKFILE" (
|
||||
"kanji" CHAR(1) NOT NULL,
|
||||
"radical" CHAR(1) NOT NULL,
|
||||
PRIMARY KEY ("kanji", "radical")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "RADK" ON "RADKFILE"("radical");
|
||||
CREATE INDEX "KRAD" ON "RADKFILE"("kanji");
|
||||
|
||||
CREATE VIEW "RADKFILE_Radicals" AS
|
||||
SELECT DISTINCT "radical" FROM "RADKFILE";
|
155
migrations/0004_KANJIDIC2.sql
Normal file
155
migrations/0004_KANJIDIC2.sql
Normal file
@ -0,0 +1,155 @@
|
||||
CREATE TABLE "KANJIDIC_Character" (
|
||||
"literal" CHAR(1) NOT NULL PRIMARY KEY,
|
||||
"grade" INTEGER CHECK ("grade" BETWEEN 1 AND 10),
|
||||
"strokeCount" INTEGER NOT NULL,
|
||||
"frequency" INTEGER,
|
||||
"jlpt" INTEGER
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_RadicalName" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"name" TEXT NOT NULL,
|
||||
PRIMARY KEY("kanji", "name")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_Codepoint" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"type" VARCHAR(6) NOT NULL CHECK ("type" IN ('jis208', 'jis212', 'jis213', 'ucs')),
|
||||
"codepoint" VARCHAR(7) NOT NULL,
|
||||
PRIMARY KEY ("kanji", "type")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Codepoint_byCharacter" ON "KANJIDIC_Codepoint"("kanji");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Radical" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"type" VARCHAR(9) NOT NULL CHECK ("type" IN ('classical', 'nelson_c')),
|
||||
"radical" INTEGER NOT NULL CHECK ("radical" BETWEEN 1 AND IIF("type" = 'classical', 214, 212)),
|
||||
PRIMARY KEY("kanji", "type")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_StrokeMiscount" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"strokeCount" INTEGER NOT NULL,
|
||||
PRIMARY KEY("kanji", "strokeCount")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_Variant" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"variant" TEXT NOT NULL,
|
||||
"type" VARCHAR(8) NOT NULL CHECK (
|
||||
"type" IN (
|
||||
'jis208',
|
||||
'jis212',
|
||||
'jis213',
|
||||
'deroo',
|
||||
'njecd',
|
||||
's_h',
|
||||
'nelson_c',
|
||||
'oneill',
|
||||
'ucs'
|
||||
)
|
||||
),
|
||||
PRIMARY KEY ("kanji", "type", "variant")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "_KANJIDIC_DictionaryReference_Part1" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"ref" VARCHAR(9) NOT NULL,
|
||||
"type" VARCHAR(16) NOT NULL CHECK(
|
||||
"type" IN (
|
||||
'nelson_c',
|
||||
'nelson_n',
|
||||
'halpern_njecd',
|
||||
'halpern_kkd',
|
||||
'halpern_kkld',
|
||||
'halpern_kkld_2ed',
|
||||
'heisig',
|
||||
'heisig6',
|
||||
'gakken',
|
||||
'oneill_names',
|
||||
'oneill_kk',
|
||||
'henshall',
|
||||
'sh_kk',
|
||||
'sh_kk2',
|
||||
'sakade',
|
||||
'jf_cards',
|
||||
'henshall3',
|
||||
'tutt_cards',
|
||||
'crowley',
|
||||
'kanji_in_context',
|
||||
'busy_people',
|
||||
'kodansha_compact',
|
||||
'maniette'
|
||||
)
|
||||
),
|
||||
PRIMARY KEY("kanji", "type")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "_KANJIDIC_DictionaryReference_Moro" (
|
||||
"kanji" CHAR(1) NOT NULL PRIMARY KEY REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"ref" VARCHAR(7) NOT NULL,
|
||||
"volume" INTEGER,
|
||||
"page" INTEGER
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_DictionaryReference_byPart1" ON "_KANJIDIC_DictionaryReference_Part1"("kanji", "ref", "type");
|
||||
CREATE INDEX "KANJIDIC_DictionaryReference_byMoro" ON "_KANJIDIC_DictionaryReference_Moro"("kanji", "ref", "volume", "page");
|
||||
|
||||
CREATE VIEW "KANJIDIC_DictionaryReference" AS
|
||||
SELECT "kanji", "ref", "type", NULL AS "volume", NULL AS "page" FROM "_KANJIDIC_DictionaryReference_Part1"
|
||||
UNION
|
||||
SELECT "kanji", "ref", 'moro' AS "type", "volume", "page" FROM "_KANJIDIC_DictionaryReference_Moro";
|
||||
|
||||
CREATE TABLE "KANJIDIC_QueryCode" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"code" VARCHAR(7) NOT NULL,
|
||||
"type" VARCHAR(11) NOT NULL CHECK ("type" IN ('skip', 'sh_desc', 'four_corner', 'deroo', 'misclass')),
|
||||
"SKIPMisclassification" VARCHAR(15),
|
||||
PRIMARY KEY ("kanji", "type", "code")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE TABLE "KANJIDIC_Reading" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"type" VARCHAR(8) NOT NULL CHECK ("type" IN ('korean_h', 'korean_r', 'pinyin')),
|
||||
"reading" TEXT NOT NULL,
|
||||
PRIMARY KEY ("kanji", "type", "reading")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Reading_byReading" ON "KANJIDIC_Reading"("reading");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Kunyomi" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"yomi" TEXT NOT NULL,
|
||||
"isJouyou" BOOLEAN,
|
||||
PRIMARY KEY ("kanji", "yomi")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Kunyomi_byYomi" ON "KANJIDIC_Kunyomi"("yomi");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Onyomi" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"yomi" TEXT NOT NULL,
|
||||
"type" VARCHAR(7) CHECK ("type" IN ('kan', 'go', 'tou', 'kan''you')),
|
||||
"isJouyou" BOOLEAN,
|
||||
PRIMARY KEY ("kanji", "yomi")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Onyomi_byYomi" ON "KANJIDIC_Onyomi"("yomi");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Meaning" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"language" CHAR(3) NOT NULL DEFAULT "eng",
|
||||
"meaning" TEXT NOT NULL,
|
||||
PRIMARY KEY ("kanji", "language", "meaning")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Meaning_byMeaning" ON "KANJIDIC_Meaning"("meaning");
|
||||
|
||||
CREATE TABLE "KANJIDIC_Nanori" (
|
||||
"kanji" CHAR(1) NOT NULL REFERENCES "KANJIDIC_Character"("literal"),
|
||||
"nanori" TEXT NOT NULL,
|
||||
PRIMARY KEY ("kanji", "nanori")
|
||||
) WITHOUT ROWID;
|
||||
|
||||
CREATE INDEX "KANJIDIC_Nanori_byNanori" ON "KANJIDIC_Nanori"("nanori");
|
6
migrations/0005_Connections.sql
Normal file
6
migrations/0005_Connections.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- Radk - kanjidic
|
||||
-- kanjireading -> filter kanji regex - kanjidic
|
||||
-- index kanji search by romaji
|
||||
-- index kanji search by hiragana
|
||||
-- index word search by romaji
|
||||
-- index word search by hiragana
|
Loading…
Reference in New Issue
Block a user