updating decks to include source language
This commit is contained in:
parent
5603f15fe3
commit
4ef70b3876
1 changed files with 10 additions and 1 deletions
|
|
@ -132,6 +132,7 @@ export const decks = pgTable(
|
||||||
id: uuid().primaryKey().defaultRandom(),
|
id: uuid().primaryKey().defaultRandom(),
|
||||||
name: text().notNull(),
|
name: text().notNull(),
|
||||||
description: text(),
|
description: text(),
|
||||||
|
source_language: varchar({ length: 10 }).notNull(),
|
||||||
validated_for_languages: varchar({ length: 10 })
|
validated_for_languages: varchar({ length: 10 })
|
||||||
.array()
|
.array()
|
||||||
.notNull()
|
.notNull()
|
||||||
|
|
@ -140,11 +141,19 @@ export const decks = pgTable(
|
||||||
created_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
created_at: timestamp({ withTimezone: true }).defaultNow().notNull(),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
|
check(
|
||||||
|
"source_language_check",
|
||||||
|
sql`${table.source_language} IN (${sql.raw(SUPPORTED_LANGUAGE_CODES.map((l) => `'${l}'`).join(", "))})`,
|
||||||
|
),
|
||||||
check(
|
check(
|
||||||
"validated_languages_check",
|
"validated_languages_check",
|
||||||
sql`validated_for_languages <@ ARRAY[${sql.raw(SUPPORTED_LANGUAGE_CODES.map((l) => `'${l}'`).join(", "))}]::varchar[]`,
|
sql`validated_for_languages <@ ARRAY[${sql.raw(SUPPORTED_LANGUAGE_CODES.map((l) => `'${l}'`).join(", "))}]::varchar[]`,
|
||||||
),
|
),
|
||||||
unique("unique_deck_name").on(table.name),
|
check(
|
||||||
|
"validated_languages_excludes_source",
|
||||||
|
sql`NOT (${table.source_language} = ANY(validated_for_languages))`,
|
||||||
|
),
|
||||||
|
unique("unique_deck_name").on(table.name, table.source_language),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue