-- Phase 97: Project Generation
-- Tabela mapowań produktów na skrypty generujące projekty graficzne
-- Kolumna project_generated w order_items

CREATE TABLE IF NOT EXISTS project_mappings (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    product_name_pattern VARCHAR(255) NOT NULL,
    script_name VARCHAR(255) NOT NULL,
    output_dir VARCHAR(500) NULL,
    is_active TINYINT(1) NOT NULL DEFAULT 1,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE order_items ADD COLUMN project_generated TINYINT(1) NOT NULL DEFAULT 0 AFTER payload_json;
ALTER TABLE order_items ADD COLUMN project_generated_at DATETIME NULL AFTER project_generated;
