Initial commit with basic DB layout
This commit is contained in:
6
migrations/2023-01-03-134426_create_language/down.sql
Normal file
6
migrations/2023-01-03-134426_create_language/down.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE LangAndAgents;
|
||||
DROP TABLE Languages;
|
||||
DROP TYPE Release;
|
||||
DROP TYPE DictGenre;
|
||||
DROP TYPE AgentLanguageRelation;
|
||||
37
migrations/2023-01-03-134426_create_language/up.sql
Normal file
37
migrations/2023-01-03-134426_create_language/up.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
-- 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),
|
||||
relese Release NOT NULL,
|
||||
targetLanguage TEXT[] NOT NULL,
|
||||
genre DictGenre[] NOT NULL,
|
||||
abstract TEXT,
|
||||
created TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||
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
|
||||
);
|
||||
Reference in New Issue
Block a user