-- +goose Up CREATE TABLE genius_state ( id boolean PRIMARY KEY DEFAULT true CHECK (id), paused boolean NOT NULL DEFAULT false, last_error text NOT NULL DEFAULT '', cooldown_until timestamptz NOT NULL DEFAULT '1970-01-01' ); INSERT INTO genius_state (id) VALUES (true); CREATE TABLE genius_tracks ( track_id uuid PRIMARY KEY REFERENCES tracks(id) ON DELETE CASCADE, status text NOT NULL DEFAULT 'pending' CHECK (status IN ('pending','processing','ready','partial','unmatched','error')), content jsonb NOT NULL DEFAULT '{}', attempts integer NOT NULL DEFAULT 0, last_error text NOT NULL DEFAULT '', next_attempt timestamptz NOT NULL DEFAULT now(), locked_until timestamptz NOT NULL DEFAULT '1970-01-01', updated_at timestamptz NOT NULL DEFAULT now() ); CREATE INDEX genius_queue_idx ON genius_tracks (next_attempt) WHERE status IN ('pending','processing','error','partial'); ALTER TABLE artists ADD COLUMN genius_image_url text; ALTER TABLE albums ADD COLUMN genius_cover_url text; -- +goose Down ALTER TABLE albums DROP COLUMN genius_cover_url; ALTER TABLE artists DROP COLUMN genius_image_url; DROP TABLE genius_tracks; DROP TABLE genius_state;