-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathticketing.sql
82 lines (71 loc) · 2.37 KB
/
ticketing.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
CREATE TABLE event_slot (
id BIGSERIAL PRIMARY KEY,
event_id BIGINT,
name VARCHAR(100),
description TEXT,
cost INTEGER,
capacity INT,
start_date TIMESTAMP WITH TIME ZONE,
end_date TIMESTAMP WITH TIME ZONE,
depends_on_id BIGINT,
purchaseable_from TIMESTAMP WITH TIME ZONE,
purchaseable_until TIMESTAMP WITH TIME ZONE,
available_to_public BOOLEAN,
FOREIGN KEY(depends_on_id) REFERENCES event_slot(id),
FOREIGN KEY(event_id) REFERENCES event(id)
);
CREATE TABLE slot_claim (
id BIGSERIAL PRIMARY KEY,
event_slot_id BIGINT,
ticket_id VARCHAR(100) CONSTrAINT ticket_id_is_unique UNIQUE,
redeemed BOOLEAN,
FOREIGN KEY(event_slot_id) REFERENCES event_slot(id)
);
CREATE TABLE attendee (
id BIGSERIAL PRIMARY KEY,
email BIGINT,
coc_accepted BOOLEAN
);
CREATE TABLE attendee_to_slot_claims (
attendee_id BIGINT,
slot_claim_id BIGINT CONSTRAINT slot_claim_id_is_unique UNIQUE,
FOREIGN KEY (attendee_id) REFERENCES attendee(id),
FOREIGN KEY (slot_claim_id) REFERENCES slot_claim(id)
);
CREATE TABLE claim_payment (
id BIGSERIAL PRIMARY KEY,
invoice TEXT -- just in case we need to store the whole thing.
);
CREATE TABLE payment_method_money (
id BIGSERIAL PRIMARY KEY,
amount INTEGER,
ref VARCHAR(250)
);
CREATE TABLE payment_method_money_to_claim_payment (
payment_method_money_id BIGINT,
claim_payment_id BIGINT,
FOREIGN KEY (payment_method_money_id) REFERENCES payment_method_money(id),
FOREIGN KEY (claim_payment_id) REFERENCES claim_payment(id)
);
CREATE TABLE payment_method_credit_note (
id BIGSERIAL PRIMARY KEY,
amount INTEGER,
detail VARCHAR(250)
);
CREATE TABLE payment_method_credit_note_to_claim_payment (
payment_method_credit_note_id BIGINT,
claim_payment_id BIGINT,
FOREIGN KEY (payment_method_credit_note_id) REFERENCES payment_method_credit_note(id),
FOREIGN KEY (claim_payment_id) REFERENCES claim_payment(id)
);
CREATE TABLE payment_method_event_discount (
id BIGSERIAL PRIMARY KEY,
amount INTEGER,
detail VARCHAR(250)
);
CREATE TABLE payment_method_event_discount_to_claim_payment (
payment_method_event_discount_id BIGINT,
claim_payment_id BIGINT,
FOREIGN KEY (payment_method_event_discount_id) REFERENCES payment_method_event_discount(id),
FOREIGN KEY (claim_payment_id) REFERENCES claim_payment(id)
);