2023-01-25 10:29:41 -05:00
|
|
|
BEGIN;
|
|
|
|
|
|
|
|
CREATE TABLE languages (
|
2023-02-18 01:41:59 -05:00
|
|
|
-- name type constraints
|
|
|
|
id BIGSERIAL PRIMARY KEY,
|
|
|
|
code VARCHAR(2) NOT NULL,
|
|
|
|
english_name VARCHAR NOT NULL,
|
|
|
|
self_name VARCHAR NOT NULL,
|
|
|
|
|
|
|
|
-- CONSTRAINT name CHECK (condition)
|
|
|
|
CONSTRAINT code_is_language_code CHECK (is_language_code(code)),
|
2023-02-04 17:46:09 -05:00
|
|
|
CONSTRAINT english_name_is_sane_text CHECK (is_sane_text(english_name)),
|
2023-02-18 01:41:59 -05:00
|
|
|
CONSTRAINT self_name_is_sane_text CHECK (is_sane_text(self_name))
|
2023-01-25 10:29:41 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
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;
|