-- Agent billing preferences and per-listing overrides (legacy)

ALTER TABLE "User"
ADD COLUMN "agentBillingEnabled" BOOLEAN NOT NULL DEFAULT FALSE,
ADD COLUMN "agentBankAccount" TEXT,
ADD COLUMN "agentVatBreakdownRequired" BOOLEAN NOT NULL DEFAULT FALSE,
ADD COLUMN "agentUseListingOverrides" BOOLEAN NOT NULL DEFAULT FALSE;

CREATE TABLE "ListingBillingSettings" (
    "id" TEXT NOT NULL,
    "listingId" TEXT NOT NULL,
    "bankAccount" TEXT,
    "vatBreakdownRequired" BOOLEAN NOT NULL DEFAULT FALSE,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT "ListingBillingSettings_pkey" PRIMARY KEY ("id"),
    CONSTRAINT "ListingBillingSettings_listingId_key" UNIQUE ("listingId"),
    CONSTRAINT "ListingBillingSettings_listingId_fkey" FOREIGN KEY ("listingId") REFERENCES "Listing"("id") ON DELETE CASCADE ON UPDATE CASCADE
);
