From acafe2849f3238eb3839ab1788e153bcce9dc761 Mon Sep 17 00:00:00 2001 From: Alyssia Tan Date: Mon, 25 Nov 2024 12:35:56 -0800 Subject: [PATCH 1/4] completed events sql --- server/db/schema/sample.sql | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 server/db/schema/sample.sql diff --git a/server/db/schema/sample.sql b/server/db/schema/sample.sql deleted file mode 100644 index 42b76b3..0000000 --- a/server/db/schema/sample.sql +++ /dev/null @@ -1,9 +0,0 @@ --- TODO: delete sample file - -DROP TABLE IF EXISTS sample CASCADE; - -CREATE TABLE sample ( - id SERIAL PRIMARY KEY, - content VARCHAR(256) NOT NULL -); - From d6f91dee3993025d010c8d4b7371c42724140560 Mon Sep 17 00:00:00 2001 From: Alyssia Tan Date: Mon, 2 Dec 2024 22:56:28 -0800 Subject: [PATCH 2/4] oops here is the file, sorry --- server/db/schema/events.sql | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 server/db/schema/events.sql diff --git a/server/db/schema/events.sql b/server/db/schema/events.sql new file mode 100644 index 0000000..7aab850 --- /dev/null +++ b/server/db/schema/events.sql @@ -0,0 +1,24 @@ +-- DROP TABLE IF EXISTS Events; +-- DROP TABLE IF EXISTS Classes; + +DROP TYPE IF EXISTS level; +CREATE TYPE level AS ENUM ('beginner', 'intermediate', 'advanced'); + +-- CREATE TABLE Classes ( +-- id SERIAL PRIMARY KEY +-- ); + +CREATE TABLE Events ( + id SERIAL PRIMARY KEY, + location VARCHAR(256) NOT NULL, + title VARCHAR(256) NOT NULL, + description TEXT, + level LEVEL NOT NULL, + date DATE NOT NULL, + start_time TIME NOT NULL, + end_time TIME NOT NULL, + call_time TIME NOT NULL, + class_id INTEGER NOT NULL, + FOREIGN KEY (class_id) REFERENCES Classes(id), + costume TEXT NOT NULL +); \ No newline at end of file From 3c7a74982a3d853ef442f9e19ea0a48651ca607d Mon Sep 17 00:00:00 2001 From: Alyssia Tan Date: Thu, 5 Dec 2024 21:32:46 -0800 Subject: [PATCH 3/4] changes made according to PL comments --- server/db/schema/events.sql | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/server/db/schema/events.sql b/server/db/schema/events.sql index 7aab850..ada7249 100644 --- a/server/db/schema/events.sql +++ b/server/db/schema/events.sql @@ -1,12 +1,7 @@ --- DROP TABLE IF EXISTS Events; --- DROP TABLE IF EXISTS Classes; - +DROP TABLE IF EXISTS Events; DROP TYPE IF EXISTS level; -CREATE TYPE level AS ENUM ('beginner', 'intermediate', 'advanced'); --- CREATE TABLE Classes ( --- id SERIAL PRIMARY KEY --- ); +CREATE TYPE LEVEL AS ENUM ('beginner', 'intermediate', 'advanced'); CREATE TABLE Events ( id SERIAL PRIMARY KEY, @@ -19,6 +14,6 @@ CREATE TABLE Events ( end_time TIME NOT NULL, call_time TIME NOT NULL, class_id INTEGER NOT NULL, - FOREIGN KEY (class_id) REFERENCES Classes(id), - costume TEXT NOT NULL + costume TEXT NOT NULL, + FOREIGN KEY (class_id) REFERENCES Classes(id) ON DELETE CASCADE ); \ No newline at end of file From 4d764744d3fa3ac07db32d1b7b2a57a74c59b8a4 Mon Sep 17 00:00:00 2001 From: Alyssia Tan Date: Thu, 5 Dec 2024 22:18:56 -0800 Subject: [PATCH 4/4] happy ethan? --- server/db/schema/events.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/db/schema/events.sql b/server/db/schema/events.sql index ada7249..e1ccabe 100644 --- a/server/db/schema/events.sql +++ b/server/db/schema/events.sql @@ -1,5 +1,5 @@ DROP TABLE IF EXISTS Events; -DROP TYPE IF EXISTS level; +DROP TYPE IF EXISTS LEVEL; CREATE TYPE LEVEL AS ENUM ('beginner', 'intermediate', 'advanced');