-- Rollback: Update expense and expense_nonstocks tables

-- Drop indexes
DROP INDEX IF EXISTS idx_expenses_project_flock_id;
DROP INDEX IF EXISTS idx_expenses_location_id;

-- Drop Foreign Key constraint
DO $$
BEGIN
    IF EXISTS (
        SELECT 1 FROM pg_constraint
        WHERE conname = 'fk_expenses_location_id'
    ) THEN
        ALTER TABLE expenses
            DROP CONSTRAINT fk_expenses_location_id;
    END IF;
END $$;

-- Drop columns from expenses table
ALTER TABLE expenses
DROP COLUMN IF EXISTS project_flock_id;

ALTER TABLE expenses
DROP COLUMN IF EXISTS location_id;
