presenceirb/DatabaseSetup.sql
Louis Vallat 7af226f08f Added Database information
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2020-11-26 23:06:14 +01:00

25 lines
585 B
SQL

DROP TABLE students, events;
CREATE TABLE IF NOT EXISTS students
(
id int GENERATED ALWAYS AS IDENTITY,
snowflake text NOT NULL,
ade_resource int NOT NULL,
PRIMARY KEY (id),
UNIQUE (snowflake)
);
CREATE TABLE IF NOT EXISTS events
(
id int GENERATED ALWAYS AS IDENTITY,
students_id int NOT NULL,
summary text NOT NULL,
start_event timestamptz NOT NULL,
end_event timestamptz NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (students_id)
REFERENCES students (id)
ON DELETE CASCADE
);