-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnova_schema.sql
More file actions
27 lines (25 loc) · 872 Bytes
/
nova_schema.sql
File metadata and controls
27 lines (25 loc) · 872 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
26
27
-- Create Nova Database Schema
-- Create users table
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
is_premium BOOLEAN DEFAULT false,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_email (email),
INDEX idx_username (username)
);
-- Create links table
CREATE TABLE IF NOT EXISTS links (
id INT AUTO_INCREMENT PRIMARY KEY,
original_url LONGTEXT NOT NULL,
short_code VARCHAR(255) NOT NULL UNIQUE,
custom BOOLEAN DEFAULT false,
user_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_short_code (short_code),
INDEX idx_user_id (user_id),
INDEX idx_original_url (original_url(255))
);