1
0
Fork 0

refactor(migrations): move migrations to db/migrations dir

This commit is contained in:
Vojtěch Mareš 2024-06-26 22:28:05 +02:00
parent 2d32c80182
commit d1a3420390
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
3 changed files with 1 additions and 1 deletions

View file

@ -1,57 +0,0 @@
BEGIN;
CREATE SCHEMA IF NOT EXISTS training;
CREATE TABLE IF NOT EXISTS training.trainings (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
slug varchar(255) NOT NULL,
description text NOT NULL,
days smallint NOT NULL
);
CREATE TABLE IF NOT EXISTS training.prices (
training_id SERIAL REFERENCES training.trainings(id),
amount NUMERIC(10,4) NOT NULL,
currency VARCHAR(3) NOT NULL,
CONSTRAINT positive_amount CHECK (amount >= 0),
CONSTRAINT allowed_currencies CHECK (currency IN ('USD', 'EUR', 'CZK')),
type VARCHAR(10) NOT NULL,
CHECK (type IN ('OPEN', 'CORPORATE')),
PRIMARY KEY (training_id, currency, type) -- composite primary key
);
CREATE TABLE IF NOT EXISTS training.dates (
id SERIAL PRIMARY KEY,
training_id SERIAL REFERENCES training.trainings(id),
date DATE NOT NULL,
start_time TIME NOT NULL,
days SMALLINT NOT NULL,
is_online BOOLEAN NOT NULL,
location VARCHAR(255) NOT NULL,
address VARCHAR(500) NOT NULL,
capacity SMALLINT NOT NULL,
price_amount NUMERIC(10,4) NOT NULL,
price_currency VARCHAR(3) NOT NULL,
CONSTRAINT positive_amount CHECK (price_amount >= 0),
CONSTRAINT allowed_currencies CHECK (price_currency IN ('USD', 'EUR', 'CZK'))
);
CREATE TABLE IF NOT EXISTS training.attendees (
id SERIAL PRIMARY KEY,
date_id SERIAL REFERENCES training.dates(id),
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phone VARCHAR(20) NOT NULL,
company VARCHAR(255) NOT NULL,
position VARCHAR(255) NOT NULL,
is_student BOOLEAN NOT NULL,
has_paid BOOLEAN NOT NULL,
has_attended BOOLEAN NOT NULL,
bill_amount NUMERIC(10,4) NOT NULL,
bill_currency VARCHAR(3) NOT NULL,
CONSTRAINT positive_amount CHECK (bill_amount >= 0),
CONSTRAINT allowed_currencies CHECK (bill_currency IN ('USD', 'EUR', 'CZK'))
);
COMMIT;