add edict
This commit is contained in:
1 parent
792fa60030
commit
8bb5d996b9
11 files changed
+132
-52
No files matched your search
+14
-40
@@ -1,17 +1,20 @@
|
||||
CREATE TABLE "entry" (
|
||||
"id" UUID NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
"id" UUID NOT NULL DEFAULT uuid_generate_v4(),
|
||||
"createdAt" TIMESTAMPTZ DEFAULT now(),
|
||||
"updatedAt" TIMESTAMPTZ DEFAULT now(),
|
||||
"userId" UUID NOT NULL REFERENCES "user"("id") ON DELETE CASCADE,
|
||||
"type" TEXT NOT NULL,
|
||||
"entry" TEXT[] NOT NULL CHECK ("entry"[1] IS NOT NULL),
|
||||
-- "reading" -- backref "entry.reading"
|
||||
-- "translation" -- backref "entry.translation"
|
||||
"reading" JSONB NOT NULL DEFAULT '{}', -- TODO: jsonschema
|
||||
"translation" JSONB NOT NULL DEFAULT '{}', -- TODO: jsonschema
|
||||
"description" TEXT NOT NULL DEFAULT '',
|
||||
"tag" TEXT[] NOT NULL DEFAULT '{}',
|
||||
"level" FLOAT NOT NULL,
|
||||
"level.kanji" INT NOT NULL,
|
||||
"frequency" FLOAT
|
||||
"level" FLOAT,
|
||||
"level.kanji" INT,
|
||||
"frequency" FLOAT,
|
||||
"key" TEXT UNIQUE,
|
||||
"_meta" JSONB, -- TODO: jsonschema
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
CREATE TRIGGER "t_entry_updatedAt"
|
||||
@@ -19,8 +22,6 @@ CREATE TRIGGER "t_entry_updatedAt"
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE "f_updatedAt"();
|
||||
|
||||
CREATE UNIQUE INDEX idx_entry_u ON "entry" (("entry"[1]), "type", "userId");
|
||||
|
||||
CREATE INDEX "idx_entry_updatedAt" ON "entry" ("updatedAt");
|
||||
CREATE INDEX "idx_entry_userId" ON "entry" ("userId");
|
||||
CREATE INDEX "idx_entry_type" ON "entry" ("type");
|
||||
@@ -41,39 +42,12 @@ CREATE INDEX "idx_entry_entry" ON "entry"
|
||||
CREATE INDEX "idx_entry_entry_gin" ON "entry" USING GIN("entry");
|
||||
CREATE INDEX "idx_entry_tag" ON "entry" USING pgroonga ("tag");
|
||||
|
||||
CREATE TABLE "entry.reading" (
|
||||
"id" UUID NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
"createdAt" TIMESTAMPTZ DEFAULT now(),
|
||||
"updatedAt" TIMESTAMPTZ DEFAULT now(),
|
||||
"userId" UUID NOT NULL REFERENCES "user"("id") ON DELETE CASCADE,
|
||||
"entryId" UUID NOT NULL REFERENCES "entry"("id") ON DELETE CASCADE,
|
||||
"type" TEXT NOT NULL,
|
||||
"reading" TEXT[] NOT NULL DEFAULT '{}' CHECK ("reading"[1] IS NOT NULL)
|
||||
);
|
||||
|
||||
CREATE INDEX "idx_entry.reading_updatedAt" ON "entry.reading" ("updatedAt");
|
||||
CREATE INDEX "idx_entry.reading_userId" ON "entry.reading" ("userId");
|
||||
CREATE INDEX "idx_entry.reading_type" ON "entry.reading" ("type");
|
||||
CREATE INDEX "idx_entry.reading_reading" ON "entry.reading"
|
||||
USING pgroonga (normalize_reading("reading"))
|
||||
CREATE INDEX "idx_entry_meta" ON "entry" USING pgroonga("_meta");
|
||||
CREATE INDEX "idx_entry_reading" ON "entry"
|
||||
USING pgroonga("reading")
|
||||
WITH (
|
||||
tokenizer='TokenMecab',
|
||||
normalizer='NormalizerNFKC100("unify_kana", true)'
|
||||
);
|
||||
|
||||
CREATE TABLE "entry.translation" (
|
||||
"id" UUID NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
"createdAt" TIMESTAMPTZ DEFAULT now(),
|
||||
"updatedAt" TIMESTAMPTZ DEFAULT now(),
|
||||
"userId" UUID NOT NULL REFERENCES "user"("id") ON DELETE CASCADE,
|
||||
"entryId" UUID NOT NULL REFERENCES "entry"("id") ON DELETE CASCADE,
|
||||
"language" TEXT NOT NULL,
|
||||
"translation" TEXT[] NOT NULL DEFAULT '{}' CHECK ("translation"[1] IS NOT NULL)
|
||||
);
|
||||
|
||||
CREATE INDEX "idx_entry.translation_updatedAt" ON "entry.translation" ("updatedAt");
|
||||
CREATE INDEX "idx_entry.translation_userId" ON "entry.translation" ("userId");
|
||||
CREATE INDEX "idx_entry.translation_language" ON "entry.translation" ("language");
|
||||
CREATE INDEX "idx_entry.translation_translation" ON "entry.translation"
|
||||
USING pgroonga("translation")
|
||||
WITH (plugins='token_filters/stem', token_filters='TokenFilterStem');
|
||||
CREATE INDEX "idx_entry_translation" ON "entry"
|
||||
USING pgroonga("translation");
|
||||
Reference in new issue
Block a user