21 lines
594 B
MySQL
21 lines
594 B
MySQL
|
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;
|