adding term examples table
This commit is contained in:
parent
e718d188d5
commit
0ac2cef6e1
4 changed files with 1228 additions and 0 deletions
12
packages/db/drizzle/0008_far_energizer.sql
Normal file
12
packages/db/drizzle/0008_far_energizer.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
CREATE TABLE "term_examples" (
|
||||||
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
"term_id" uuid NOT NULL,
|
||||||
|
"language_code" varchar(10) NOT NULL,
|
||||||
|
"text" text NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
CONSTRAINT "unique_term_example" UNIQUE("term_id","language_code","text"),
|
||||||
|
CONSTRAINT "language_code_check" CHECK ("term_examples"."language_code" IN ('en', 'it', 'de', 'fr', 'es'))
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "term_examples" ADD CONSTRAINT "term_examples_term_id_terms_id_fk" FOREIGN KEY ("term_id") REFERENCES "public"."terms"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
CREATE INDEX "idx_term_examples_term_id" ON "term_examples" USING btree ("term_id","language_code");
|
||||||
1184
packages/db/drizzle/meta/0008_snapshot.json
Normal file
1184
packages/db/drizzle/meta/0008_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -57,6 +57,13 @@
|
||||||
"when": 1776665111607,
|
"when": 1776665111607,
|
||||||
"tag": "0007_nosy_leper_queen",
|
"tag": "0007_nosy_leper_queen",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 8,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1776695279870,
|
||||||
|
"tag": "0008_far_energizer",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +63,31 @@ export const term_glosses = pgTable(
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const term_examples = pgTable(
|
||||||
|
"term_examples",
|
||||||
|
{
|
||||||
|
id: uuid().primaryKey().defaultRandom(),
|
||||||
|
term_id: uuid()
|
||||||
|
.notNull()
|
||||||
|
.references(() => terms.id, { onDelete: "cascade" }),
|
||||||
|
language_code: varchar({ length: 10 }).notNull(),
|
||||||
|
text: text().notNull(),
|
||||||
|
created_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
unique("unique_term_example").on(
|
||||||
|
table.term_id,
|
||||||
|
table.language_code,
|
||||||
|
table.text,
|
||||||
|
),
|
||||||
|
check(
|
||||||
|
"language_code_check",
|
||||||
|
sql`${table.language_code} IN (${sql.raw(SUPPORTED_LANGUAGE_CODES.map((l) => `'${l}'`).join(", "))})`,
|
||||||
|
),
|
||||||
|
index("idx_term_examples_term_id").on(table.term_id, table.language_code),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
export const translations = pgTable(
|
export const translations = pgTable(
|
||||||
"translations",
|
"translations",
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue