-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d84293
commit f1cdd7e
Showing
36 changed files
with
356 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
BEGIN; | ||
|
||
DROP TABLE IF EXISTS clubs CASCADE; | ||
|
||
DROP TABLE IF EXISTS events CASCADE; | ||
|
||
DROP TABLE IF EXISTS users CASCADE; | ||
|
||
DROP TABLE IF EXISTS categories CASCADE; | ||
|
||
DROP TABLE IF EXISTS tags CASCADE; | ||
|
||
DROP TABLE IF EXISTS club_events CASCADE; | ||
|
||
DROP TABLE IF EXISTS club_tags CASCADE; | ||
|
||
DROP TABLE IF EXISTS contacts CASCADE; | ||
|
||
DROP TABLE IF EXISTS series CASCADE; | ||
|
||
DROP TABLE IF EXISTS event_series CASCADE; | ||
|
||
DROP TABLE IF EXISTS event_tags CASCADE; | ||
|
||
DROP TABLE IF EXISTS files CASCADE; | ||
|
||
DROP TABLE IF EXISTS notifications CASCADE; | ||
|
||
DROP TABLE IF EXISTS point_of_contacts CASCADE; | ||
|
||
DROP TABLE IF EXISTS user_club_followers CASCADE; | ||
|
||
DROP TABLE IF EXISTS user_club_intended_applicants CASCADE; | ||
|
||
DROP TABLE IF EXISTS user_club_members CASCADE; | ||
|
||
DROP TABLE IF EXISTS user_event_rsvps CASCADE; | ||
|
||
DROP TABLE IF EXISTS user_event_waitlists CASCADE; | ||
|
||
DROP TABLE IF EXISTS user_tags CASCADE; | ||
|
||
DROP TABLE IF EXISTS verifications CASCADE; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
BEGIN; | ||
|
||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; | ||
|
||
CREATE TABLE IF NOT EXISTS users( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
role varchar(255) NOT NULL DEFAULT 'student'::character varying, | ||
first_name varchar(255) NOT NULL, | ||
last_name varchar(255) NOT NULL, | ||
email varchar(255) NOT NULL, | ||
password_hash varchar(97) NOT NULL, | ||
major0 varchar(255), | ||
major1 varchar(255), | ||
major2 varchar(255), | ||
college varchar(255), | ||
graduation_cycle varchar(255), | ||
graduation_year smallint, | ||
is_verified boolean NOT NULL DEFAULT false, | ||
PRIMARY KEY(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS clubs( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
soft_deleted_at timestamp with time zone, | ||
name varchar(255) NOT NULL, | ||
preview varchar(255) NOT NULL, | ||
description text NOT NULL, | ||
num_members bigint NOT NULL, | ||
is_recruiting boolean NOT NULL DEFAULT false, | ||
recruitment_cycle varchar(255) NOT NULL DEFAULT 'always'::character varying, | ||
recruitment_type varchar(255) NOT NULL DEFAULT 'unrestricted'::character varying, | ||
weekly_time_commitment bigint, | ||
one_word_to_describe_us varchar(255) DEFAULT NULL::character varying, | ||
application_link varchar(255) DEFAULT NULL::character varying, | ||
logo varchar(255) DEFAULT NULL::character varying, | ||
parent text, | ||
PRIMARY KEY(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS events( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
name varchar(255) NOT NULL, | ||
preview varchar(255) NOT NULL, | ||
content text NOT NULL, | ||
start_time timestamp with time zone NOT NULL, | ||
end_time timestamp with time zone NOT NULL, | ||
location varchar(255) NOT NULL, | ||
event_type varchar(255) NOT NULL DEFAULT 'open'::character varying, | ||
is_recurring boolean NOT NULL DEFAULT false, | ||
meeting_link varchar(255), | ||
host uuid NOT NULL, | ||
PRIMARY KEY(id), | ||
CONSTRAINT fk_clubs_host_event FOREIGN key(host) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS categories( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
name varchar(255) NOT NULL, | ||
PRIMARY KEY(id) | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS uni_categories_name ON categories USING btree ("name"); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS tags( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
name varchar(255) NOT NULL, | ||
category_id uuid NOT NULL, | ||
PRIMARY KEY(id), | ||
CONSTRAINT fk_categories_tag FOREIGN key(category_id) REFERENCES categories(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS club_events( | ||
club_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
event_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(club_id,event_id), | ||
CONSTRAINT fk_club_events_event FOREIGN key(event_id) REFERENCES events(id), | ||
CONSTRAINT fk_club_events_club FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS club_tags( | ||
tag_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
club_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(tag_id,club_id), | ||
CONSTRAINT fk_club_tags_tag FOREIGN key(tag_id) REFERENCES tags(id), | ||
CONSTRAINT fk_club_tags_club FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS contacts( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"type" varchar(255) NOT NULL, | ||
content varchar(255) NOT NULL, | ||
club_id uuid NOT NULL, | ||
PRIMARY KEY(id), | ||
CONSTRAINT fk_clubs_contact FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS idx_contact_type ON contacts USING btree ("type","club_id"); | ||
|
||
CREATE TABLE IF NOT EXISTS series( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
recurring_type varchar(255) NOT NULL DEFAULT 'open'::character varying, | ||
max_occurrences bigint NOT NULL, | ||
PRIMARY KEY(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS event_series( | ||
event_id uuid NOT NULL, | ||
series_id uuid NOT NULL, | ||
CONSTRAINT fk_event_series_event FOREIGN key(event_id) REFERENCES events(id), | ||
CONSTRAINT fk_event_series_series FOREIGN key(series_id) REFERENCES series(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS event_tags( | ||
tag_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
event_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(tag_id,event_id), | ||
CONSTRAINT fk_event_tags_tag FOREIGN key(tag_id) REFERENCES tags(id), | ||
CONSTRAINT fk_event_tags_event FOREIGN key(event_id) REFERENCES events(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS files( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
owner_id uuid NOT NULL, | ||
owner_type varchar(255) NOT NULL, | ||
file_name varchar(255) NOT NULL, | ||
file_type varchar(255) NOT NULL, | ||
file_size bigint NOT NULL, | ||
file_url varchar(255) NOT NULL, | ||
object_key varchar(255) NOT NULL, | ||
PRIMARY KEY(id) | ||
); | ||
CREATE INDEX IF NOT EXISTS idx_files_owner_type ON files USING btree ("owner_type"); | ||
CREATE INDEX IF NOT EXISTS idx_files_owner_id ON files USING btree ("owner_id"); | ||
|
||
-- CREATE TABLE IF NOT EXISTS notifications( | ||
-- id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
-- created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
-- updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
-- send_at timestamp with time zone NOT NULL, | ||
-- title varchar(255) NOT NULL, | ||
-- content varchar(255) NOT NULL, | ||
-- deep_link varchar(255) NOT NULL, | ||
-- icon varchar(255) NOT NULL, | ||
-- reference_id uuid NOT NULL, | ||
-- reference_type varchar(255) NOT NULL, | ||
-- PRIMARY KEY(id) | ||
-- ); | ||
|
||
CREATE TABLE IF NOT EXISTS point_of_contacts( | ||
id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
name varchar(255) NOT NULL, | ||
email varchar(255) NOT NULL, | ||
position varchar(255) NOT NULL, | ||
club_id uuid NOT NULL, | ||
PRIMARY KEY(id), | ||
CONSTRAINT fk_clubs_point_of_contact FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
CREATE UNIQUE INDEX IF NOT EXISTS compositeindex ON point_of_contacts USING btree ("email","club_id"); | ||
CREATE INDEX IF NOT EXISTS idx_point_of_contacts_club_id ON point_of_contacts USING btree ("club_id"); | ||
CREATE INDEX IF NOT EXISTS idx_point_of_contacts_email ON point_of_contacts USING btree ("email"); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS user_club_followers( | ||
user_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
club_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(user_id,club_id), | ||
CONSTRAINT fk_user_club_followers_user FOREIGN key(user_id) REFERENCES users(id), | ||
CONSTRAINT fk_user_club_followers_club FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS user_club_intended_applicants( | ||
user_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
club_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(user_id,club_id), | ||
CONSTRAINT fk_user_club_intended_applicants_user FOREIGN key(user_id) REFERENCES users(id), | ||
CONSTRAINT fk_user_club_intended_applicants_club FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS user_club_members( | ||
user_id uuid NOT NULL, | ||
club_id uuid NOT NULL, | ||
membership_type varchar(255) NOT NULL DEFAULT 'member'::character varying, | ||
PRIMARY KEY(user_id,club_id), | ||
CONSTRAINT fk_user_club_members_user FOREIGN key(user_id) REFERENCES users(id), | ||
CONSTRAINT fk_user_club_members_club FOREIGN key(club_id) REFERENCES clubs(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS user_event_rsvps( | ||
user_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
event_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(user_id,event_id), | ||
CONSTRAINT fk_user_event_rsvps_user FOREIGN key(user_id) REFERENCES users(id), | ||
CONSTRAINT fk_user_event_rsvps_event FOREIGN key(event_id) REFERENCES events(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS user_event_waitlists( | ||
user_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
event_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(user_id,event_id), | ||
CONSTRAINT fk_user_event_waitlists_user FOREIGN key(user_id) REFERENCES users(id), | ||
CONSTRAINT fk_user_event_waitlists_event FOREIGN key(event_id) REFERENCES events(id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS user_tags( | ||
user_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
tag_id uuid NOT NULL DEFAULT uuid_generate_v4(), | ||
PRIMARY KEY(user_id,tag_id), | ||
CONSTRAINT fk_user_tags_user FOREIGN key(user_id) REFERENCES users(id), | ||
CONSTRAINT fk_user_tags_tag FOREIGN key(tag_id) REFERENCES tags(id) | ||
); | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS uni_users_email ON users USING btree ("email"); | ||
|
||
CREATE TABLE IF NOT EXISTS verifications( | ||
user_id varchar(36) NOT NULL, | ||
token varchar(255), | ||
expires_at timestamp without time zone NOT NULL, | ||
"type" varchar(255) NOT NULL, | ||
PRIMARY KEY(user_id,expires_at) | ||
); | ||
CREATE UNIQUE INDEX IF NOT EXISTS uni_verifications_token ON verifications USING btree ("token"); | ||
|
||
COMMIT; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.