CREATE TABLE `contact_submissions` (
    `id` VARCHAR(191) NOT NULL,
    `name` VARCHAR(120) NOT NULL,
    `email` VARCHAR(120) NOT NULL,
    `phone` VARCHAR(15) NOT NULL,
    `state` VARCHAR(80) NOT NULL,
    `city` VARCHAR(80) NOT NULL,
    `subject` ENUM('LISTING_ISSUE', 'DEALER_VERIFICATION', 'PAYMENT_SUPPORT', 'OTHERS') NOT NULL,
    `message` TEXT NOT NULL,
    `user_id` VARCHAR(191) NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),

    INDEX `contact_submissions_created_at_idx`(`created_at`),
    INDEX `contact_submissions_subject_created_at_idx`(`subject`, `created_at`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

ALTER TABLE `contact_submissions` ADD CONSTRAINT `contact_submissions_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;
