Skip to content

Commit

Permalink
Added migration sql scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
stranck committed Oct 16, 2024
1 parent 8edd932 commit b3c436d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 3 deletions.
12 changes: 12 additions & 0 deletions db/migrations/000001_create_users_table.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DROP TABLE IF EXISTS events;
DROP TABLE IF EXISTS groups;
DROP TABLE IF EXISTS tags;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS fursuits_events;
DROP TABLE IF EXISTS authentications;
DROP TABLE IF EXISTS media;
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS rooms;
DROP TABLE IF EXISTS user_group;
DROP TABLE IF EXISTS fursuits;
DROP TABLE IF EXISTS room_guests;
128 changes: 128 additions & 0 deletions db/migrations/000001_create_users_table.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
CREATE TABLE IF NOT EXISTS events (
event_slug varchar(255) NOT NULL,
event_date_end varchar(32) NULL,
event_date_from varchar(32) NULL,
event_is_current bool NULL,
event_public_url text NULL,
event_names text NULL,
CONSTRAINT events_pkey PRIMARY KEY (event_slug)
);

CREATE TABLE IF NOT EXISTS groups (
group_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
group_name varchar(255) NOT NULL,
CONSTRAINT groups_pkey PRIMARY KEY (group_id)
);

CREATE TABLE IF NOT EXISTS tags (
tag_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
tag_code varchar(255) NULL,
CONSTRAINT tags_pkey PRIMARY KEY (tag_id),
CONSTRAINT tags_unique_code UNIQUE (tag_code)
);

CREATE TABLE IF NOT EXISTS users (
user_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
user_first_name varchar(255) NULL,
user_last_name varchar(255) NULL,
user_fursona_name varchar(32) NULL,
user_locale varchar(8) DEFAULT 'en'::character varying NULL,
user_secret varchar(70) NOT NULL,
CONSTRAINT users_pkey PRIMARY KEY (user_id)
);

CREATE TABLE IF NOT EXISTS fursuits_events (
event_id int8 NOT NULL,
fursuit_id int8 NOT NULL,
CONSTRAINT fursuits_events_pk PRIMARY KEY (event_id, fursuit_id)
);

CREATE TABLE IF NOT EXISTS authentications (
authentication_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
authentication_email varchar(255) NOT NULL,
authentication_email_verified bool NULL,
authentication_2fa_enabled bool NULL,
authentication_disabled bool NULL,
authentication_expired bool NULL,
authentication_from_oauth bool NULL,
authentication_password text NOT NULL,
authentication_token varchar(255) NULL,
user_id int8 NULL,
CONSTRAINT authentications_pkey PRIMARY KEY (authentication_id),
CONSTRAINT authentications_unique_email UNIQUE (authentication_email),
CONSTRAINT authentications_unique_user_id UNIQUE (user_id),
CONSTRAINT authentications_users_fk FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE TABLE IF NOT EXISTS media (
media_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
media_path text NULL,
media_type varchar(255) NULL,
user_id int8 NULL,
tag_ids _int8 NULL,
CONSTRAINT media_pkey PRIMARY KEY (media_id),
CONSTRAINT media_users_fk FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE TABLE IF NOT EXISTS orders (
order_code varchar(64) NOT NULL,
order_answers text NULL,
order_status int2 NOT NULL,
order_answers_main_position_id int4 NOT NULL,
order_daily_days int8 NOT NULL,
order_extra_days_type int2 NULL,
has_membership bool NOT NULL,
order_secret varchar(32) NULL,
order_sponsorship_type int2 NULL,
event_id varchar(255) NULL,
user_id int8 NULL,
order_status int2 DEFAULT 0 NOT NULL,
CONSTRAINT orders_extra_days_check CHECK (((order_extra_days_type >= 0) AND (order_extra_days_type <= 3))),
CONSTRAINT orders_pkey PRIMARY KEY (order_code),
CONSTRAINT orders_sponsorship_check CHECK (((order_sponsorship_type >= 0) AND (order_sponsorship_type <= 2))),
CONSTRAINT orders_status_check CHECK (((order_status >= 0) AND (order_status <= 3))),
CONSTRAINT orders_events_id FOREIGN KEY (event_id) REFERENCES events(event_slug),
CONSTRAINT orders_users_id FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE TABLE IF NOT EXISTS rooms (
room_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
room_confirmed bool NULL,
room_name varchar(255) NULL,
order_id varchar(64) NULL,
CONSTRAINT rooms_pkey PRIMARY KEY (room_id),
CONSTRAINT rooms_unique_order_id UNIQUE (order_id),
CONSTRAINT rooms_orders_id FOREIGN KEY (order_id) REFERENCES orders(order_code)
);



CREATE TABLE IF NOT EXISTS user_group (
user_group_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
group_id int8 NULL,
user_id int8 NULL,
CONSTRAINT user_group_pkey PRIMARY KEY (user_group_id),
CONSTRAINT user_group_groups_fk FOREIGN KEY (group_id) REFERENCES "groups"(group_id),
CONSTRAINT user_group_users_fk FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE TABLE IF NOT EXISTS fursuits (
fursuit_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
fursuit_name varchar(255) NULL,
fursuit_species varchar(255) NULL,
user_id int8 NULL,
media_id int8 NULL,
CONSTRAINT fursuits_pkey PRIMARY KEY (fursuit_id),
CONSTRAINT fursuits_unique_media_id UNIQUE (media_id),
CONSTRAINT fursuits_media_fk FOREIGN KEY (media_id) REFERENCES media(media_id),
CONSTRAINT fursuits_users_fk FOREIGN KEY (user_id) REFERENCES users(user_id)
);

CREATE TABLE IF NOT EXISTS room_guests (
room_guest_id int8 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL,
user_id int8 NULL,
room_id int8 NULL,
CONSTRAINT room_guests_pkey PRIMARY KEY (room_guest_id),
CONSTRAINT room_guests_rooms_fk FOREIGN KEY (room_id) REFERENCES rooms(room_id),
CONSTRAINT room_guests_users_fk FOREIGN KEY (user_id) REFERENCES users(user_id)
);
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ private List<Pair<String, String>> reloadOrganizers() throws TimeoutException {
public void reloadEvents() throws TimeoutException {
List<Pair<String, String>> organizers = reloadOrganizers();

//List<Event> ret = new LinkedList<>();
String currentEvent = pretixConfig.getCurrentEvent();
String currentOrg = pretixConfig.getOrganizer();
for(Pair<String, String> organizerPair : organizers){
Expand Down Expand Up @@ -301,7 +300,6 @@ public void reloadEvents() throws TimeoutException {
}
});
}
//return ret;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@RequiredArgsConstructor
public enum OrderStatus {
PENDING("n"), PAID("p"), EXPIRED("e"), CANCELED("c");
CANCELED("c"), PENDING("n"), PAID("p"), EXPIRED("e");

@Getter
private final String code;
Expand Down

0 comments on commit b3c436d

Please sign in to comment.