-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
25 lines (25 loc) · 877 Bytes
/
init.sql
File metadata and controls
25 lines (25 loc) · 877 Bytes
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
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(100) NOT NULL UNIQUE,
wallet_address VARCHAR(255),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE games (
id INT AUTO_INCREMENT PRIMARY KEY,
player1_id INT NOT NULL,
player2_id INT NOT NULL,
winner_id INT NOT NULL,
stake_amount DECIMAL(10, 3) NOT NULL,
completed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (player1_id) REFERENCES users(id),
FOREIGN KEY (player2_id) REFERENCES users(id)
);
CREATE TABLE friends (
id INT AUTO_INCREMENT PRIMARY KEY,
requester_id INT NOT NULL,
addressee_id INT NOT NULL,
status BOOLEAN DEFAULT FALSE,
FOREIGN KEY (requester_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (addressee_id) REFERENCES users(id) ON DELETE CASCADE
);