BEGIN;

DO $$
BEGIN
    IF EXISTS (
        SELECT 1
        FROM information_schema.columns
        WHERE table_schema = 'public'
          AND table_name = 'project_flocks'
          AND column_name = 'fcr_id'
    ) THEN
        IF EXISTS (
            SELECT 1
            FROM pg_constraint
            WHERE conname = 'project_flocks_fcr_id_fkey'
        ) THEN
            ALTER TABLE project_flocks
                DROP CONSTRAINT project_flocks_fcr_id_fkey;
        END IF;

        ALTER TABLE project_flocks
            DROP COLUMN fcr_id;
    END IF;
END $$;

COMMIT;
