Add words
This commit is contained in:
parent
e4ef43cb72
commit
1dbf4b868f
2 changed files with 30 additions and 0 deletions
5
20230211045705_words.down.sql
Normal file
5
20230211045705_words.down.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
BEGIN;
|
||||
DROP TABLE word_form_example_texts;
|
||||
DROP TABLE word_forms;
|
||||
DROP TABLE words;
|
||||
COMMIT;
|
25
20230211045705_words.up.sql
Normal file
25
20230211045705_words.up.sql
Normal file
|
@ -0,0 +1,25 @@
|
|||
BEGIN;
|
||||
|
||||
CREATE TABLE words (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
language_id BIGINT NOT NULL REFERENCES languages (id),
|
||||
primary_form VARCHAR NOT NULL,
|
||||
CONSTRAINT primary_form_is_sane_text CHECK (is_sane_text(primary_form))
|
||||
);
|
||||
|
||||
CREATE TABLE word_forms (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
word_id BIGINT NOT NULL REFERENCES words (id),
|
||||
value VARCHAR NOT NULL,
|
||||
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
|
||||
);
|
||||
|
||||
CREATE TABLE word_form_example_texts (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
word_form_id BIGINT NOT NULL REFERENCES word_forms (id),
|
||||
example_text_id BIGINT NOT NULL REFERENCES example_texts (id)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX word_forms_word_value_index ON word_forms (word_id, value);
|
||||
|
||||
COMMIT;
|
Loading…
Reference in a new issue