1
0
Fork 0

Translate language names

This commit is contained in:
Alex Kotov 2023-02-18 13:06:34 +04:00
parent 02366261ac
commit cc1b2a793f
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,4 @@
BEGIN;
ALTER TABLE languages ALTER COLUMN english_name SET NOT NULL;
ALTER TABLE languages ALTER COLUMN self_name SET NOT NULL;
COMMIT;

View file

@ -0,0 +1,4 @@
BEGIN;
ALTER TABLE languages ALTER COLUMN english_name DROP NOT NULL;
ALTER TABLE languages ALTER COLUMN self_name DROP NOT NULL;
COMMIT;

View file

@ -0,0 +1,15 @@
BEGIN;
DROP TABLE language_names;
ALTER TABLE languages ADD COLUMN english_name VARCHAR;
ALTER TABLE languages ADD COLUMN self_name VARCHAR;
ALTER TABLE languages ADD CONSTRAINT english_name_is_sane_text
CHECK (english_name IS NULL OR is_sane_text(english_name));
ALTER TABLE languages ADD CONSTRAINT self_name_is_sane_text
CHECK (self_name IS NULL OR is_sane_text(self_name));
CREATE UNIQUE INDEX languages_english_name ON languages (english_name);
COMMIT;

View file

@ -0,0 +1,20 @@
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;