1
0
Fork 0

Add examples

This commit is contained in:
Alex Kotov 2023-02-05 03:11:56 +04:00
parent eca4794f2f
commit e4ef43cb72
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,4 @@
BEGIN;
DROP TABLE example_texts;
DROP TABLE examples;
COMMIT;

View 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;