From 91b057b0fbd9054e6c62d053eff31483cf4aec9f Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 25 Jan 2023 19:29:41 +0400 Subject: [PATCH] Add languages --- 20230125152306_languages.down.sql | 3 +++ 20230125152306_languages.up.sql | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 20230125152306_languages.down.sql create mode 100644 20230125152306_languages.up.sql diff --git a/20230125152306_languages.down.sql b/20230125152306_languages.down.sql new file mode 100644 index 0000000..4d36f7f --- /dev/null +++ b/20230125152306_languages.down.sql @@ -0,0 +1,3 @@ +BEGIN; +DROP TABLE languages; +COMMIT; diff --git a/20230125152306_languages.up.sql b/20230125152306_languages.up.sql new file mode 100644 index 0000000..a3cbab7 --- /dev/null +++ b/20230125152306_languages.up.sql @@ -0,0 +1,23 @@ +BEGIN; + +CREATE TABLE languages ( + id BIGSERIAL PRIMARY KEY, + code VARCHAR(2) NOT NULL, + english_name VARCHAR NOT NULL, + self_name VARCHAR NOT NULL, + CONSTRAINT code_is_language_code CHECK (is_language_code(code)), + CONSTRAINT english_name_is_name CHECK (is_name(english_name)), + CONSTRAINT self_name_is_name CHECK (is_name(self_name)) +); + +CREATE UNIQUE INDEX languages_code ON languages (code); +CREATE UNIQUE INDEX languages_english_name ON languages (english_name); + +INSERT INTO languages (code, english_name, self_name) VALUES + ('en', 'English', 'English'), + ('ru', 'Russian', 'Русский'), + ('pl', 'Polish', 'Polski'), + ('es', 'Spanish', 'Español'), + ('ka', 'Georgian', 'ქართული'); + +COMMIT;