-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema_sqlite.sql
More file actions
30 lines (25 loc) · 922 Bytes
/
Copy pathschema_sqlite.sql
File metadata and controls
30 lines (25 loc) · 922 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
28
29
30
-- Basic catalog schema (SQLite)
-- Stores known songs and their fingerprint hashes.
CREATE TABLE IF NOT EXISTS songs (
song_id TEXT PRIMARY KEY,
title TEXT,
artist TEXT,
file_path TEXT NOT NULL,
duration_sec REAL,
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS fingerprints (
hash INTEGER NOT NULL,
time_sec REAL NOT NULL,
song_id TEXT NOT NULL REFERENCES songs(song_id) ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS idx_fingerprints_hash ON fingerprints(hash);
CREATE INDEX IF NOT EXISTS idx_fingerprints_song_id ON fingerprints(song_id);
CREATE TABLE IF NOT EXISTS users (
user_id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
role TEXT NOT NULL CHECK (role IN ('admin', 'user')),
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);