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

20 lines
577 B
MySQL
Raw Normal View History

2023-02-18 05:07:01 -05:00
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;