1
0
Fork 0
database/20230218100109_translate_parts.up.sql

19 lines
577 B
PL/PgSQL

BEGIN;
CREATE TABLE part_names (
-- name type constraints
id BIGSERIAL PRIMARY KEY,
part_id BIGINT NOT NULL REFERENCES parts (id),
name_lang_id BIGINT NOT NULL REFERENCES languages (id),
value VARCHAR NOT NULL,
-- CONSTRAINT name CHECK (condition)
CONSTRAINT value_is_sane_text CHECK (is_sane_text(value))
);
CREATE UNIQUE INDEX part_names_part_name_lang
ON part_names (part_id, name_lang_id);
CREATE UNIQUE INDEX part_names_name_lang_value
ON part_names (name_lang_id, value);
COMMIT;