ordabok/migrations/2023-01-03-134426_create_language/up.sql

38 lines
973 B
MySQL
Raw Normal View History

2023-01-03 14:16:10 +00:00
-- Your SQL goes here
CREATE TYPE Release as ENUM ('PUBLIC', 'NONCOMMERCIAL', 'RESEARCH', 'PRIVATE');
CREATE TYPE DictGenre as ENUM ('gen', 'lrn', 'ety', 'spe', 'his', 'ort', 'trm');
CREATE TYPE AgentLanguageRelation as ENUM ('publisher', 'author');
CREATE TABLE Languages (
name VARCHAR(255) PRIMARY KEY,
native VARCHAR(255),
2023-01-03 15:11:43 +00:00
release Release NOT NULL,
2023-01-03 14:16:10 +00:00
targetLanguage TEXT[] NOT NULL,
genre DictGenre[] NOT NULL,
abstract TEXT,
2023-01-03 15:11:43 +00:00
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
2023-01-03 14:16:10 +00:00
description TEXT,
rights TEXT,
license TEXT,
owner VARCHAR(31)
REFERENCES Users(id)
ON UPDATE CASCADE
ON DELETE CASCADE
NOT NULL
);
CREATE TABLE LangAndAgents (
id SERIAL PRIMARY KEY,
agent VARCHAR(31)
REFERENCES Users(id)
ON UPDATE CASCADE
ON DELETE CASCADE
NOT NULL,
language VARCHAR(255)
REFERENCES Languages(name)
ON UPDATE CASCADE
ON DELETE CASCADE
NOT NULL,
relationship AgentLanguageRelation NOT NULL
);