CREATE TABLE IF NOT EXISTS catalog_quote_requests (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    shop_id BIGINT UNSIGNED NULL,
    shop_product_id BIGINT UNSIGNED NULL,
    source_product_id BIGINT UNSIGNED NULL,
    user_id BIGINT UNSIGNED NULL,
    request_kind VARCHAR(32) NOT NULL DEFAULT 'pricing',
    status VARCHAR(32) NOT NULL DEFAULT 'new',
    product_name VARCHAR(190) NOT NULL,
    product_sku VARCHAR(120) NULL,
    shop_name VARCHAR(190) NULL,
    contact_first_name VARCHAR(120) NOT NULL,
    contact_last_name VARCHAR(120) NOT NULL,
    contact_email VARCHAR(190) NOT NULL,
    contact_phone VARCHAR(60) NULL,
    company VARCHAR(190) NULL,
    base_quantity INT UNSIGNED NOT NULL DEFAULT 1,
    visual_count INT UNSIGNED NOT NULL DEFAULT 1,
    total_quantity INT UNSIGNED NOT NULL DEFAULT 1,
    criteria_json JSON NULL,
    criteria_labels_json JSON NULL,
    product_snapshot_json JSON NULL,
    message TEXT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_catalog_quote_requests_status (status),
    INDEX idx_catalog_quote_requests_product (shop_product_id, source_product_id),
    INDEX idx_catalog_quote_requests_shop (shop_id),
    INDEX idx_catalog_quote_requests_email (contact_email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
