1
0
Fork 0
database/20230218083503_translate.up.sql

20 lines
594 B
PL/PgSQL

BEGIN;
ALTER TABLE languages DROP COLUMN english_name;
ALTER TABLE languages DROP COLUMN self_name;
CREATE TABLE language_names (
-- name type constraints
id BIGSERIAL PRIMARY KEY,
lang_id BIGINT NOT NULL REFERENCES languages (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 languages_lang_name_lang
ON language_names (lang_id, name_lang_id);
COMMIT;