-- Smart playlists: playlists that are a set of rules, worked out again every time they are opened. -- Only the rules are kept (as JSON, read and written by the code, never searched), with the order -- and the most songs they give. CREATE TABLE smart_playlists ( id INTEGER PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE, name TEXT NOT NULL, description TEXT NOT NULL DEFAULT '', rules TEXT NOT NULL, sort TEXT NOT NULL, max_tracks INTEGER NOT NULL, created_at INTEGER NOT NULL, -- unix seconds updated_at INTEGER NOT NULL ); CREATE INDEX idx_smart_playlists_user ON smart_playlists(user_id, updated_at);