-- Add migration tracking fields for Cloudflare for SaaS transition
-- These fields track whether a dealer has been migrated from the old DNS system
-- (managed zones / self-managed A records) to the new CNAME-based system

ALTER TABLE "Dealer" ADD COLUMN "customDomainMigrated" BOOLEAN NOT NULL DEFAULT false;
ALTER TABLE "Dealer" ADD COLUMN "customDomainMigratedAt" TIMESTAMP(3);

-- Add index for querying dealers that need migration
CREATE INDEX "Dealer_customDomainMigrated_idx" ON "Dealer" ("customDomainMigrated")
WHERE "customDomain" IS NOT NULL AND "customDomainMigrated" = false;
