DROP INDEX IF EXISTS idx_publish_records_enterprise_site_active;
DROP INDEX IF EXISTS uk_publish_records_batch_enterprise_site;

DELETE FROM publish_records
WHERE target_type = 'enterprise_site';

ALTER TABLE publish_records
    DROP CONSTRAINT IF EXISTS ck_publish_records_target_ref,
    DROP CONSTRAINT IF EXISTS ck_publish_records_target_type,
    DROP COLUMN IF EXISTS target_connection_id,
    DROP COLUMN IF EXISTS target_type;

ALTER TABLE publish_records
    ALTER COLUMN platform_account_id SET NOT NULL;

DELETE FROM media_platforms
WHERE platform_id = 'pbootcms';

DROP TABLE IF EXISTS enterprise_site_categories;
DROP TABLE IF EXISTS enterprise_site_connections;
