1+ -- =============================================================================
2+ -- Statistics Tables
3+ -- =============================================================================
4+
5+ -- Table to manage refund requests for transactions.
6+ CREATE TABLE IF NOT EXISTS refunds (
7+ id INTEGER PRIMARY KEY AUTOINCREMENT,
8+ user_id INTEGER NOT NULL ,
9+ transaction_id INTEGER NOT NULL ,
10+ authorizer_id INTEGER ,
11+ status SMALLINT NOT NULL DEFAULT 0 ,
12+ created_timestamp TEXT NOT NULL DEFAULT (datetime(' now' )),
13+ approved_timestamp TEXT ,
14+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT,
15+ FOREIGN KEY (transaction_id) REFERENCES transactions(id) ON DELETE RESTRICT,
16+ FOREIGN KEY (authorizer_id) REFERENCES users(id) ON DELETE RESTRICT
17+ );
18+
19+ -- Table to queue and track emails that need to be sent.
20+ CREATE TABLE IF NOT EXISTS email_tasks (
21+ id INTEGER PRIMARY KEY AUTOINCREMENT,
22+ user_id INTEGER NOT NULL ,
23+ type TEXT NOT NULL ,
24+ custom_message TEXT ,
25+ created_timestamp TEXT NOT NULL DEFAULT (datetime(' now' )),
26+ sent_timestamp TEXT ,
27+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE RESTRICT
28+ );
29+
30+ -- =============================================================================
31+ -- Modified Tables
32+ -- =============================================================================
33+
34+ -- Add status column to transactions table to track refunds
35+ ALTER TABLE transactions
36+ ADD COLUMN status SMALLINT NOT NULL DEFAULT 0 ;
0 commit comments