-- AlterTable
ALTER TABLE `Lead` ADD COLUMN `zohoLeadId` VARCHAR(191) NULL,
    ADD COLUMN `zohoSyncStatus` VARCHAR(191) NOT NULL DEFAULT 'pending',
    ADD COLUMN `zohoSyncedAt` DATETIME(3) NULL,
    ADD COLUMN `zohoError` TEXT NULL;

-- CreateIndex
CREATE INDEX `Lead_zohoSyncStatus_idx` ON `Lead`(`zohoSyncStatus`);

-- CreateTable
CREATE TABLE `ZohoSyncLog` (
    `id` VARCHAR(191) NOT NULL,
    `entity` VARCHAR(191) NOT NULL,
    `entityId` VARCHAR(191) NOT NULL,
    `action` VARCHAR(191) NOT NULL,
    `direction` VARCHAR(191) NOT NULL,
    `zohoId` VARCHAR(191) NULL,
    `status` VARCHAR(191) NOT NULL,
    `payload` TEXT NULL,
    `error` TEXT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

    INDEX `ZohoSyncLog_entity_entityId_idx`(`entity`, `entityId`),
    INDEX `ZohoSyncLog_createdAt_idx`(`createdAt`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AlterTable Property
ALTER TABLE `Property` ADD COLUMN `zohoRecordId` VARCHAR(191) NULL;

-- AlterTable LandListing
ALTER TABLE `LandListing` ADD COLUMN `zohoRecordId` VARCHAR(191) NULL;

-- AlterTable Project
ALTER TABLE `Project` ADD COLUMN `zohoRecordId` VARCHAR(191) NULL;
