-- CreateTable
CREATE TABLE `projecttype` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL,
    `isActive` BOOLEAN NOT NULL DEFAULT true,
    `order` INTEGER NOT NULL DEFAULT 0,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `projecttype_name_key`(`name`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `feature` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL,
    `isActive` BOOLEAN NOT NULL DEFAULT true,
    `order` INTEGER NOT NULL DEFAULT 0,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `feature_name_key`(`name`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `budgetoption` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `range` VARCHAR(191) NOT NULL,
    `isActive` BOOLEAN NOT NULL DEFAULT true,
    `order` INTEGER NOT NULL DEFAULT 0,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `budgetoption_range_key`(`range`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `timelineoption` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `duration` VARCHAR(191) NOT NULL,
    `isActive` BOOLEAN NOT NULL DEFAULT true,
    `order` INTEGER NOT NULL DEFAULT 0,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `timelineoption_duration_key`(`duration`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `quoteformsettings` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `featuresTitle` VARCHAR(191) NOT NULL DEFAULT 'Features you''re interested in',
    `additionalFeaturesTitle` VARCHAR(191) NOT NULL DEFAULT 'Any other features or requirements?',
    `budgetEnabled` BOOLEAN NOT NULL DEFAULT true,
    `timelineEnabled` BOOLEAN NOT NULL DEFAULT true,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `quoterequest` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `requestId` VARCHAR(191) NOT NULL,
    `status` ENUM('PENDING', 'REVIEWING', 'QUOTED', 'ACCEPTED', 'DECLINED', 'COMPLETED') NOT NULL DEFAULT 'PENDING',
    `estimatedPrice` DECIMAL(10, 2) NULL,
    `adminNotes` TEXT NULL,
    `projectTypeId` INTEGER NULL,
    `selectedFeatures` JSON NOT NULL,
    `additionalFeatures` TEXT NULL,
    `budgetOptionId` INTEGER NULL,
    `timelineOptionId` INTEGER NULL,
    `fullName` VARCHAR(191) NOT NULL,
    `email` VARCHAR(191) NOT NULL,
    `phone` VARCHAR(191) NOT NULL,
    `preferredContact` VARCHAR(191) NOT NULL,
    `additionalInfo` TEXT NULL,
    `accessPassword` VARCHAR(191) NOT NULL,
    `lastAccessed` DATETIME(3) NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `quoterequest_requestId_key`(`requestId`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `quoterequest` ADD CONSTRAINT `quoterequest_projectTypeId_fkey` FOREIGN KEY (`projectTypeId`) REFERENCES `projecttype`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `quoterequest` ADD CONSTRAINT `quoterequest_budgetOptionId_fkey` FOREIGN KEY (`budgetOptionId`) REFERENCES `budgetoption`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `quoterequest` ADD CONSTRAINT `quoterequest_timelineOptionId_fkey` FOREIGN KEY (`timelineOptionId`) REFERENCES `timelineoption`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
