mirror of
https://github.com/screentinker/screentinker.git
synced 2026-05-15 07:32:23 -06:00
Phase 2 schema: add playlist_id to devices/schedules, is_auto_generated to playlists
Every device will point to exactly one playlist. Schedules can temporarily override a device's playlist. Auto-generated playlists (from migration) are flagged so the UI can filter them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
19fc38a59e
commit
2af3cec8a6
|
|
@ -54,6 +54,10 @@ const migrations = [
|
||||||
"ALTER TABLE plans ADD COLUMN stripe_price_yearly TEXT",
|
"ALTER TABLE plans ADD COLUMN stripe_price_yearly TEXT",
|
||||||
// Last login tracking
|
// Last login tracking
|
||||||
"ALTER TABLE users ADD COLUMN last_login INTEGER",
|
"ALTER TABLE users ADD COLUMN last_login INTEGER",
|
||||||
|
// Phase 2: every device gets a playlist, schedules can override with a playlist
|
||||||
|
"ALTER TABLE devices ADD COLUMN playlist_id TEXT REFERENCES playlists(id) ON DELETE SET NULL",
|
||||||
|
"ALTER TABLE schedules ADD COLUMN playlist_id TEXT REFERENCES playlists(id) ON DELETE SET NULL",
|
||||||
|
"ALTER TABLE playlists ADD COLUMN is_auto_generated INTEGER NOT NULL DEFAULT 0",
|
||||||
];
|
];
|
||||||
for (const sql of migrations) {
|
for (const sql of migrations) {
|
||||||
try { db.exec(sql); } catch (e) { /* already exists */ }
|
try { db.exec(sql); } catch (e) { /* already exists */ }
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ CREATE TABLE IF NOT EXISTS devices (
|
||||||
app_version TEXT,
|
app_version TEXT,
|
||||||
screen_width INTEGER,
|
screen_width INTEGER,
|
||||||
screen_height INTEGER,
|
screen_height INTEGER,
|
||||||
|
playlist_id TEXT REFERENCES playlists(id) ON DELETE SET NULL,
|
||||||
created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
||||||
updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now'))
|
updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now'))
|
||||||
);
|
);
|
||||||
|
|
@ -199,6 +200,7 @@ CREATE TABLE IF NOT EXISTS schedules (
|
||||||
content_id TEXT REFERENCES content(id) ON DELETE CASCADE,
|
content_id TEXT REFERENCES content(id) ON DELETE CASCADE,
|
||||||
widget_id TEXT REFERENCES widgets(id) ON DELETE CASCADE,
|
widget_id TEXT REFERENCES widgets(id) ON DELETE CASCADE,
|
||||||
layout_id TEXT REFERENCES layouts(id) ON DELETE SET NULL,
|
layout_id TEXT REFERENCES layouts(id) ON DELETE SET NULL,
|
||||||
|
playlist_id TEXT REFERENCES playlists(id) ON DELETE SET NULL,
|
||||||
title TEXT NOT NULL DEFAULT '',
|
title TEXT NOT NULL DEFAULT '',
|
||||||
start_time TEXT NOT NULL,
|
start_time TEXT NOT NULL,
|
||||||
end_time TEXT NOT NULL,
|
end_time TEXT NOT NULL,
|
||||||
|
|
@ -318,6 +320,7 @@ CREATE TABLE IF NOT EXISTS playlists (
|
||||||
user_id TEXT NOT NULL REFERENCES users(id),
|
user_id TEXT NOT NULL REFERENCES users(id),
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
description TEXT DEFAULT '',
|
description TEXT DEFAULT '',
|
||||||
|
is_auto_generated INTEGER NOT NULL DEFAULT 0,
|
||||||
created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
||||||
updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now'))
|
updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now'))
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue