Add examples
This commit is contained in:
parent
eca4794f2f
commit
e4ef43cb72
2 changed files with 24 additions and 0 deletions
4
20230204224830_examples.down.sql
Normal file
4
20230204224830_examples.down.sql
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
BEGIN;
|
||||||
|
DROP TABLE example_texts;
|
||||||
|
DROP TABLE examples;
|
||||||
|
COMMIT;
|
20
20230204224830_examples.up.sql
Normal file
20
20230204224830_examples.up.sql
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE TABLE examples (
|
||||||
|
id BIGSERIAL PRIMARY KEY
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE example_texts (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
example_id BIGINT NOT NULL REFERENCES examples (id),
|
||||||
|
language_id BIGINT NOT NULL REFERENCES languages (id),
|
||||||
|
index BIGINT NOT NULL,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
CONSTRAINT index_is_not_negative CHECK(index >= 0),
|
||||||
|
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX example_texts_example_language_index
|
||||||
|
ON example_texts (example_id, language_id, index);
|
||||||
|
|
||||||
|
COMMIT;
|
Loading…
Reference in a new issue