Add translations
This commit is contained in:
parent
4daf40fc6b
commit
772b562f24
2 changed files with 32 additions and 0 deletions
4
20230218130437_translations.down.sql
Normal file
4
20230218130437_translations.down.sql
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
BEGIN;
|
||||||
|
DROP TABLE translation_texts;
|
||||||
|
DROP TABLE translations;
|
||||||
|
COMMIT;
|
28
20230218130437_translations.up.sql
Normal file
28
20230218130437_translations.up.sql
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE TABLE translations (
|
||||||
|
-- name type constraints
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
word_id BIGINT NOT NULL REFERENCES words (id),
|
||||||
|
index BIGINT NOT NULL,
|
||||||
|
|
||||||
|
-- CONSTRAINT name CHECK (condition)
|
||||||
|
CONSTRAINT index_is_not_negative CHECK (index >= 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE translation_texts (
|
||||||
|
-- name type constraints
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
translation_id BIGINT NOT NULL REFERENCES translations (id),
|
||||||
|
lang_id BIGINT NOT NULL REFERENCES languages (id),
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
|
||||||
|
-- CONSTRAINT name CHECK (condition)
|
||||||
|
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX translations_word_index ON translations (word_id, index);
|
||||||
|
CREATE UNIQUE INDEX translation_texts_translation_lang
|
||||||
|
ON translation_texts (translation_id, lang_id);
|
||||||
|
|
||||||
|
COMMIT;
|
Loading…
Reference in a new issue