-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql.sql
More file actions
22 lines (20 loc) · 680 Bytes
/
sql.sql
File metadata and controls
22 lines (20 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CREATE TABLE links (
short_url TEXT PRIMARY KEY,
long_url TEXT NOT NULL,
redirects INTEGER DEFAULT 0,
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
expire_time DATETIME,
created_by VARCHAR(50) DEFAULT NULL,
last_redirect DATETIME DEFAULT NULL,
is_active BOOLEAN DEFAULT TRUE,
FOREIGN KEY(created_by) REFERENCES users(username)
);
CREATE INDEX idx_links_long_url ON links (long_url);
CREATE TABLE users (
username VARCHAR(50) PRIMARY KEY,
password_hash VARCHAR(32) NOT NULL,
salt VARCHAR(20) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
links_created INTEGER DEFAULT 0,
last_login DATETIME DEFAULT NULL
);