Translate language names
This commit is contained in:
parent
02366261ac
commit
cc1b2a793f
4 changed files with 43 additions and 0 deletions
4
20230218081558_do_not_require_language_names.down.sql
Normal file
4
20230218081558_do_not_require_language_names.down.sql
Normal 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;
|
4
20230218081558_do_not_require_language_names.up.sql
Normal file
4
20230218081558_do_not_require_language_names.up.sql
Normal 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;
|
15
20230218083503_translate.down.sql
Normal file
15
20230218083503_translate.down.sql
Normal 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;
|
20
20230218083503_translate.up.sql
Normal file
20
20230218083503_translate.up.sql
Normal 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;
|
Loading…
Reference in a new issue