-- Smart playlists: playlists that are a set of rules, worked out again every time they are opened. -- PostgreSQL flavour of sqlite/0020_smart_playlists.sql. CREATE TABLE smart_playlists ( id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, user_id BIGINT 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 BIGINT NOT NULL, -- unix seconds updated_at BIGINT NOT NULL ); CREATE INDEX idx_smart_playlists_user ON smart_playlists(user_id, updated_at);