1
0
Fork 0
database/20230218073436_parts.up.sql
2023-02-18 11:49:16 +04:00

18 lines
515 B
PL/PgSQL

BEGIN;
CREATE TABLE parts (
-- name type constraints
id BIGSERIAL PRIMARY KEY,
language_id BIGINT NOT NULL REFERENCES languages (id),
english_name VARCHAR NOT NULL,
-- CONSTRAINT name CHECK (condition)
CONSTRAINT english_name_is_sane_text CHECK (is_sane_text(english_name))
);
CREATE UNIQUE INDEX parts_language_english_name
ON parts (language_id, english_name);
ALTER TABLE words ADD COLUMN part_id BIGINT REFERENCES parts (id);
COMMIT;