feat: add initial migration
This commit is contained in:
parent
c340623721
commit
c877fa0d2c
2 changed files with 58 additions and 0 deletions
8
db/migrations/20240329172935_init.down.sql
Normal file
8
db/migrations/20240329172935_init.down.sql
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS training.attendees;
|
||||||
|
DROP TABLE IF EXISTS training.dates;
|
||||||
|
DROP TABLE IF EXISTS training.trainings;
|
||||||
|
DROP SCHEMA IF EXISTS training;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
50
db/migrations/20240329172935_init.up.sql
Normal file
50
db/migrations/20240329172935_init.up.sql
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
CREATE SCHEMA IF NOT EXISTS training;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS training.trainings (
|
||||||
|
id UUID PRIMARY KEY,
|
||||||
|
name varchar(255) NOT NULL,
|
||||||
|
description text NOT NULL,
|
||||||
|
days smallint NOT NULL,
|
||||||
|
price decimal NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS training.dates (
|
||||||
|
id UUID PRIMARY KEY,
|
||||||
|
training_id UUID NOT NULL,
|
||||||
|
date date NOT NULL,
|
||||||
|
start_time time NOT NULL,
|
||||||
|
days smallint NOT NULL,
|
||||||
|
price decimal NOT NULL,
|
||||||
|
is_online boolean NOT NULL,
|
||||||
|
location varchar(255) NOT NULL,
|
||||||
|
address varchar(255) NOT NULL,
|
||||||
|
capacity smallint NOT NULL,
|
||||||
|
FOREIGN KEY (training_id) REFERENCES training.trainings(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS training.attendees (
|
||||||
|
id UUID PRIMARY KEY,
|
||||||
|
date_id UUID NOT NULL,
|
||||||
|
name varchar(255) NOT NULL,
|
||||||
|
email varchar(255) NOT NULL,
|
||||||
|
company varchar(255) NOT NULL,
|
||||||
|
role varchar(255) NOT NULL,
|
||||||
|
is_student boolean NOT NULL,
|
||||||
|
has_attended boolean NOT NULL,
|
||||||
|
has_paid boolean NOT NULL,
|
||||||
|
FOREIGN KEY (date_id) REFERENCES training.dates(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS training.feedback (
|
||||||
|
id UUID PRIMARY KEY,
|
||||||
|
attendee_id UUID NOT NULL,
|
||||||
|
rating smallint NOT NULL,
|
||||||
|
comment text NOT NULL,
|
||||||
|
is_anonymous boolean NOT NULL,
|
||||||
|
is_sharing_allowed boolean NOT NULL,
|
||||||
|
FOREIGN KEY (attendee_id) REFERENCES training.attendees(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
Reference in a new issue