| 1 | SET statement_timeout = 0;
|
|---|
| 2 | SET lock_timeout = 0;
|
|---|
| 3 | SET idle_in_transaction_session_timeout = 0;
|
|---|
| 4 | SET transaction_timeout = 0;
|
|---|
| 5 | SET client_encoding = 'UTF8';
|
|---|
| 6 | SET standard_conforming_strings = on;
|
|---|
| 7 | SET search_path = public;
|
|---|
| 8 | SET check_function_bodies = false;
|
|---|
| 9 | SET xmloption = content;
|
|---|
| 10 | SET client_min_messages = warning;
|
|---|
| 11 | SET row_security = off;
|
|---|
| 12 |
|
|---|
| 13 | CREATE TABLE public.user_app (
|
|---|
| 14 | user_id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 15 | username varchar(20) NOT NULL UNIQUE,
|
|---|
| 16 | email varchar(50) NOT NULL UNIQUE,
|
|---|
| 17 | contact_phone varchar(50),
|
|---|
| 18 | CONSTRAINT chk_email_format CHECK (email LIKE '%@%.%')
|
|---|
| 19 | );
|
|---|
| 20 |
|
|---|
| 21 | CREATE TABLE public.order_status (
|
|---|
| 22 | status_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 23 | status_name varchar(50) NOT NULL UNIQUE
|
|---|
| 24 | );
|
|---|
| 25 |
|
|---|
| 26 | CREATE TABLE public.event_status (
|
|---|
| 27 | event_status_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 28 | status_name varchar(50) NOT NULL UNIQUE
|
|---|
| 29 | );
|
|---|
| 30 |
|
|---|
| 31 | CREATE TABLE public.category (
|
|---|
| 32 | id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 33 | name varchar(100) NOT NULL UNIQUE
|
|---|
| 34 | );
|
|---|
| 35 |
|
|---|
| 36 | CREATE TABLE public.attribute (
|
|---|
| 37 | attribute_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 38 | name text NOT NULL,
|
|---|
| 39 | data_type varchar(20) NOT NULL,
|
|---|
| 40 | description text,
|
|---|
| 41 | is_required boolean NOT NULL
|
|---|
| 42 | );
|
|---|
| 43 |
|
|---|
| 44 | CREATE TABLE public.promo_code (
|
|---|
| 45 | promo_code_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 46 | code varchar(64) NOT NULL UNIQUE
|
|---|
| 47 | );
|
|---|
| 48 |
|
|---|
| 49 | CREATE TABLE public.location_type (
|
|---|
| 50 | type_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 51 | type_name varchar(100) NOT NULL UNIQUE
|
|---|
| 52 | );
|
|---|
| 53 |
|
|---|
| 54 | CREATE TABLE public.location (
|
|---|
| 55 | location_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 56 | name varchar(100) NOT NULL,
|
|---|
| 57 | type_id integer NOT NULL REFERENCES public.location_type(type_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 58 | address varchar(255),
|
|---|
| 59 | city varchar(255) NOT NULL,
|
|---|
| 60 | capacity integer NOT NULL,
|
|---|
| 61 | CONSTRAINT chk_location_capacity CHECK (capacity > 0)
|
|---|
| 62 | );
|
|---|
| 63 |
|
|---|
| 64 | CREATE TABLE public.section (
|
|---|
| 65 | section_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 66 | section_name varchar(100),
|
|---|
| 67 | capacity integer NOT NULL,
|
|---|
| 68 | location_id integer NOT NULL REFERENCES public.location(location_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 69 | CONSTRAINT chk_section_capacity CHECK (capacity > 0)
|
|---|
| 70 | );
|
|---|
| 71 |
|
|---|
| 72 | CREATE TABLE public.seat (
|
|---|
| 73 | seat_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 74 | row_identifier varchar(10) NOT NULL,
|
|---|
| 75 | section_id integer NOT NULL REFERENCES public.section(section_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 76 | seat_number varchar(10) NOT NULL,
|
|---|
| 77 | is_accessible boolean NOT NULL,
|
|---|
| 78 | is_available boolean NOT NULL
|
|---|
| 79 | );
|
|---|
| 80 |
|
|---|
| 81 | CREATE TABLE public.organiser (
|
|---|
| 82 | organiser_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 83 | company_name varchar(255) NOT NULL,
|
|---|
| 84 | contact_phone varchar(50),
|
|---|
| 85 | website_url varchar(255)
|
|---|
| 86 | );
|
|---|
| 87 |
|
|---|
| 88 | CREATE TABLE public.event (
|
|---|
| 89 | event_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 90 | event_status_id integer NOT NULL REFERENCES public.event_status(event_status_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 91 | title varchar(64) NOT NULL,
|
|---|
| 92 | start_datetime timestamp without time zone NOT NULL,
|
|---|
| 93 | end_datetime timestamp without time zone,
|
|---|
| 94 | CONSTRAINT chk_event_chronology CHECK (end_datetime > start_datetime)
|
|---|
| 95 | );
|
|---|
| 96 |
|
|---|
| 97 | CREATE TABLE public.event_organiser (
|
|---|
| 98 | event_organiser_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 99 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 100 | organiser_id integer NOT NULL REFERENCES public.organiser(organiser_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 101 | CONSTRAINT uq_event_organiser UNIQUE (event_id, organiser_id)
|
|---|
| 102 | );
|
|---|
| 103 |
|
|---|
| 104 | CREATE TABLE public.event_category (
|
|---|
| 105 | event_category_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 106 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 107 | category_id integer NOT NULL REFERENCES public.category(id) ON UPDATE CASCADE ON DELETE CASCADE
|
|---|
| 108 | );
|
|---|
| 109 |
|
|---|
| 110 | CREATE TABLE public.event_schedule_session (
|
|---|
| 111 | schedule_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 112 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 113 | session_title varchar(50),
|
|---|
| 114 | start_time timestamp without time zone,
|
|---|
| 115 | end_time timestamp without time zone,
|
|---|
| 116 | section_id integer NOT NULL REFERENCES public.section(section_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 117 | CONSTRAINT chk_session_chronology CHECK (end_time > start_time)
|
|---|
| 118 | );
|
|---|
| 119 |
|
|---|
| 120 | CREATE TABLE public.field (
|
|---|
| 121 | field_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 122 | field_name varchar(50) NOT NULL
|
|---|
| 123 | );
|
|---|
| 124 |
|
|---|
| 125 | CREATE TABLE public.exhibitor (
|
|---|
| 126 | exhibitor_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 127 | name varchar(50) NOT NULL,
|
|---|
| 128 | surname varchar(50),
|
|---|
| 129 | field_id integer NOT NULL REFERENCES public.field(field_id) ON UPDATE CASCADE ON DELETE RESTRICT
|
|---|
| 130 | );
|
|---|
| 131 |
|
|---|
| 132 | CREATE TABLE public.exhibitor_event_schedule_session (
|
|---|
| 133 | exhibitor_event_schedule_session_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 134 | exhibitor_id integer NOT NULL REFERENCES public.exhibitor(exhibitor_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 135 | event_schedule_session_id integer NOT NULL REFERENCES public.event_schedule_session(schedule_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 136 | start_time timestamp without time zone NOT NULL,
|
|---|
| 137 | end_time timestamp without time zone NOT NULL,
|
|---|
| 138 | CONSTRAINT chk_exhibitor_session_chronology CHECK (end_time > start_time),
|
|---|
| 139 | CONSTRAINT uq_exhibitor_session UNIQUE (exhibitor_id, event_schedule_session_id)
|
|---|
| 140 | );
|
|---|
| 141 |
|
|---|
| 142 | CREATE TABLE public.discount (
|
|---|
| 143 | discount_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 144 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 145 | discount_percent numeric(5,2) NOT NULL,
|
|---|
| 146 | promo_code_id integer REFERENCES public.promo_code(promo_code_id) ON UPDATE CASCADE ON DELETE SET NULL,
|
|---|
| 147 | CONSTRAINT chk_discount_percent CHECK (discount_percent >= 0 AND discount_percent <= 100)
|
|---|
| 148 | );
|
|---|
| 149 |
|
|---|
| 150 | CREATE TABLE public.order_cart (
|
|---|
| 151 | order_id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 152 | user_id bigint NOT NULL REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 153 | discount_id integer REFERENCES public.discount(discount_id) ON UPDATE CASCADE ON DELETE SET NULL,
|
|---|
| 154 | status_id integer NOT NULL REFERENCES public.order_status(status_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 155 | created_at timestamp without time zone NOT NULL,
|
|---|
| 156 | total_price numeric(12,2) NOT NULL,
|
|---|
| 157 | CONSTRAINT chk_order_total CHECK (total_price >= 0)
|
|---|
| 158 | );
|
|---|
| 159 |
|
|---|
| 160 | CREATE TABLE public.payment_method (
|
|---|
| 161 | method_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 162 | method_name varchar(50) NOT NULL UNIQUE
|
|---|
| 163 | );
|
|---|
| 164 |
|
|---|
| 165 | CREATE TABLE public.payment (
|
|---|
| 166 | payment_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 167 | order_id bigint NOT NULL REFERENCES public.order_cart(order_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 168 | method_id integer NOT NULL REFERENCES public.payment_method(method_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 169 | amount_paid numeric(12,2),
|
|---|
| 170 | processed_at timestamp without time zone NOT NULL,
|
|---|
| 171 | transaction_id varchar(255) NOT NULL,
|
|---|
| 172 | is_refunded boolean,
|
|---|
| 173 | CONSTRAINT chk_payment_amount CHECK (amount_paid >= 0)
|
|---|
| 174 | );
|
|---|
| 175 |
|
|---|
| 176 | CREATE TABLE public.refund_request (
|
|---|
| 177 | refund_request_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 178 | reason text,
|
|---|
| 179 | requested_at timestamp without time zone NOT NULL,
|
|---|
| 180 | accepted_at timestamp without time zone,
|
|---|
| 181 | user_id bigint NOT NULL REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 182 | payment_id integer NOT NULL REFERENCES public.payment(payment_id) ON UPDATE CASCADE ON DELETE CASCADE
|
|---|
| 183 | );
|
|---|
| 184 |
|
|---|
| 185 | CREATE TABLE public.review (
|
|---|
| 186 | review_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 187 | user_id bigint NOT NULL REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 188 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 189 | star_rating integer NOT NULL,
|
|---|
| 190 | review_text text,
|
|---|
| 191 | created_at timestamp without time zone NOT NULL,
|
|---|
| 192 | CONSTRAINT chk_star_rating CHECK (star_rating >= 1 AND star_rating <= 5),
|
|---|
| 193 | CONSTRAINT uq_user_event_review UNIQUE (user_id, event_id)
|
|---|
| 194 | );
|
|---|
| 195 |
|
|---|
| 196 | CREATE TABLE public.ticket_type (
|
|---|
| 197 | ticket_type_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 198 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 199 | tier_name varchar(100) NOT NULL,
|
|---|
| 200 | total_allocated integer NOT NULL,
|
|---|
| 201 | presale_start timestamp without time zone,
|
|---|
| 202 | presale_end timestamp without time zone,
|
|---|
| 203 | CONSTRAINT chk_presale_chronology CHECK (presale_end > presale_start),
|
|---|
| 204 | CONSTRAINT chk_ticket_allocated CHECK (total_allocated >= 0)
|
|---|
| 205 | );
|
|---|
| 206 |
|
|---|
| 207 | CREATE TABLE public.price_tier (
|
|---|
| 208 | price_tier_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 209 | ticket_type_id integer NOT NULL REFERENCES public.ticket_type(ticket_type_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 210 | price numeric(10,2) NOT NULL,
|
|---|
| 211 | valid_from timestamp without time zone NOT NULL,
|
|---|
| 212 | valid_to timestamp without time zone NOT NULL,
|
|---|
| 213 | CONSTRAINT chk_price CHECK (price >= 0),
|
|---|
| 214 | CONSTRAINT chk_price_tier_chronology CHECK (valid_to > valid_from)
|
|---|
| 215 | );
|
|---|
| 216 |
|
|---|
| 217 | CREATE TABLE public.ticket (
|
|---|
| 218 | ticket_id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 219 | order_id bigint NOT NULL REFERENCES public.order_cart(order_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 220 | ticket_type_id integer NOT NULL REFERENCES public.ticket_type(ticket_type_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 221 | event_schedule_session_id integer NOT NULL REFERENCES public.event_schedule_session(schedule_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 222 | lock_expires_at timestamp without time zone NOT NULL,
|
|---|
| 223 | status varchar(50) NOT NULL,
|
|---|
| 224 | barcode_hash varchar(255) NOT NULL UNIQUE,
|
|---|
| 225 | seat_id integer REFERENCES public.seat(seat_id) ON UPDATE CASCADE ON DELETE SET NULL,
|
|---|
| 226 | is_scanned boolean NOT NULL,
|
|---|
| 227 | scanned_at timestamp without time zone,
|
|---|
| 228 | is_presale boolean NOT NULL,
|
|---|
| 229 | CONSTRAINT chk_ticket_scanned_at_consistency CHECK (
|
|---|
| 230 | (is_scanned = true AND scanned_at IS NOT NULL)
|
|---|
| 231 | OR
|
|---|
| 232 | (is_scanned = false AND scanned_at IS NULL)
|
|---|
| 233 | )
|
|---|
| 234 | );
|
|---|
| 235 |
|
|---|
| 236 | CREATE TABLE public.sponsor (
|
|---|
| 237 | sponsor_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 238 | name varchar(64) NOT NULL UNIQUE
|
|---|
| 239 | );
|
|---|
| 240 |
|
|---|
| 241 | CREATE TABLE public.sponsor_event (
|
|---|
| 242 | sponsor_event_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 243 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 244 | sponsor_id integer NOT NULL REFERENCES public.sponsor(sponsor_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 245 | sponsor_type varchar(64) NOT NULL,
|
|---|
| 246 | sponsor_amount_paid numeric(5,2) NOT NULL,
|
|---|
| 247 | CONSTRAINT chk_sponsor_amount CHECK (sponsor_amount_paid >= 0)
|
|---|
| 248 | );
|
|---|
| 249 |
|
|---|
| 250 | CREATE TABLE public.sponsor_type (
|
|---|
| 251 | sponsor_type_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 252 | sponsor_amount_paid numeric(5,2) NOT NULL,
|
|---|
| 253 | type varchar(64) NOT NULL,
|
|---|
| 254 | CONSTRAINT chk_sponsor_type_amount CHECK (sponsor_amount_paid >= 0)
|
|---|
| 255 | );
|
|---|
| 256 |
|
|---|
| 257 | CREATE TABLE public.sponsor_type_sponsor (
|
|---|
| 258 | sponsor_type_sponsor_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 259 | sponsor_id integer NOT NULL REFERENCES public.sponsor(sponsor_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 260 | sponsor_type_id integer NOT NULL REFERENCES public.sponsor_type(sponsor_type_id) ON UPDATE CASCADE ON DELETE CASCADE
|
|---|
| 261 | );
|
|---|
| 262 |
|
|---|
| 263 | CREATE TABLE public.staff_role (
|
|---|
| 264 | staff_role_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 265 | description varchar(100) NOT NULL
|
|---|
| 266 | );
|
|---|
| 267 |
|
|---|
| 268 | CREATE TABLE public.staff_team (
|
|---|
| 269 | staff_team_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 270 | team_name varchar(50) NOT NULL
|
|---|
| 271 | );
|
|---|
| 272 |
|
|---|
| 273 | CREATE TABLE public.staff_member (
|
|---|
| 274 | staff_member_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 275 | assigned_role integer NOT NULL REFERENCES public.staff_role(staff_role_id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|---|
| 276 | name varchar(20) NOT NULL,
|
|---|
| 277 | surname varchar(20) NOT NULL,
|
|---|
| 278 | contact_phone varchar(50),
|
|---|
| 279 | staff_team_id integer NOT NULL REFERENCES public.staff_team(staff_team_id) ON UPDATE CASCADE ON DELETE RESTRICT
|
|---|
| 280 | );
|
|---|
| 281 |
|
|---|
| 282 | CREATE TABLE public.staff_team_event_schedule (
|
|---|
| 283 | schedule_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 284 | shift_start timestamp without time zone NOT NULL,
|
|---|
| 285 | shift_end timestamp without time zone NOT NULL,
|
|---|
| 286 | is_available boolean DEFAULT true NOT NULL,
|
|---|
| 287 | staff_team_id integer NOT NULL REFERENCES public.staff_team(staff_team_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 288 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 289 | CONSTRAINT chk_shift_chronology CHECK (shift_end > shift_start)
|
|---|
| 290 | );
|
|---|
| 291 |
|
|---|
| 292 | CREATE TABLE public.subscription_location (
|
|---|
| 293 | subscription_location_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 294 | user_id bigint NOT NULL REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 295 | location_id integer NOT NULL REFERENCES public.location(location_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 296 | created_at timestamp without time zone NOT NULL,
|
|---|
| 297 | CONSTRAINT uq_user_location_sub UNIQUE (user_id, location_id)
|
|---|
| 298 | );
|
|---|
| 299 |
|
|---|
| 300 | CREATE TABLE public.subscription_organiser (
|
|---|
| 301 | subscription_organiser_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 302 | user_id bigint NOT NULL REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 303 | organiser_id integer NOT NULL REFERENCES public.organiser(organiser_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 304 | created_at timestamp without time zone NOT NULL,
|
|---|
| 305 | CONSTRAINT uq_user_organiser_sub UNIQUE (user_id, organiser_id)
|
|---|
| 306 | );
|
|---|
| 307 |
|
|---|
| 308 | CREATE TABLE public.value (
|
|---|
| 309 | value_id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 310 | attribute_id integer NOT NULL REFERENCES public.attribute(attribute_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 311 | value_string text,
|
|---|
| 312 | value_int integer,
|
|---|
| 313 | value_datetime timestamp without time zone,
|
|---|
| 314 | value_bool boolean,
|
|---|
| 315 | event_id integer NOT NULL REFERENCES public.event(event_id) ON UPDATE CASCADE ON DELETE CASCADE
|
|---|
| 316 | );
|
|---|
| 317 |
|
|---|
| 318 | CREATE TABLE public.waitlist_entry (
|
|---|
| 319 | waitlist_id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|---|
| 320 | joined_at timestamp without time zone NOT NULL,
|
|---|
| 321 | status varchar(20) NOT NULL,
|
|---|
| 322 | notified_at timestamp without time zone,
|
|---|
| 323 | expires_at timestamp without time zone,
|
|---|
| 324 | user_id bigint NOT NULL REFERENCES public.user_app(user_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 325 | event_schedule_session_id integer NOT NULL REFERENCES public.event_schedule_session(schedule_id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|---|
| 326 | CONSTRAINT uq_user_session_waitlist UNIQUE (user_id, event_schedule_session_id)
|
|---|
| 327 | );
|
|---|