23 lines
775 B
PL/PgSQL
23 lines
775 B
PL/PgSQL
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_sane_text CHECK (is_sane_text(english_name)),
|
|
CONSTRAINT self_name_is_sane_text CHECK (is_sane_text(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;
|