-- Rollback: Remove id column and restore composite PK

-- Step 1: Drop indexes created in up migration
DROP INDEX IF EXISTS idx_song_soundtrack_id;
DROP INDEX IF EXISTS idx_song_path;

-- Step 2: Drop foreign key constraint
ALTER TABLE song DROP CONSTRAINT IF EXISTS song_soundtrack_id_fkey;

-- Step 3: Drop new primary key
ALTER TABLE song DROP CONSTRAINT song_pkey;

-- Step 4: Drop unique constraint on id
ALTER TABLE song DROP CONSTRAINT IF EXISTS song_id_unique;

-- Step 5: Restore composite primary key
ALTER TABLE song ADD CONSTRAINT song_pkey PRIMARY KEY (soundtrack_id, path);

-- Step 6: Drop the id column
ALTER TABLE song DROP COLUMN id;

-- Step 7: Recreate original foreign key (soundtrack_id references soundtrack.id)
ALTER TABLE song ADD CONSTRAINT song_soundtrack_id_fkey 
    FOREIGN KEY (soundtrack_id) REFERENCES soundtrack(id);
