CREATE TABLE IF NOT EXISTS order_status_mappings (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    integration_id INT UNSIGNED NOT NULL,
    shoppro_status_code VARCHAR(64) NOT NULL,
    shoppro_status_name VARCHAR(128) NULL,
    orderpro_status_code VARCHAR(64) NOT NULL,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY order_status_mappings_integration_shoppro_unique (integration_id, shoppro_status_code),
    KEY order_status_mappings_integration_idx (integration_id),
    KEY order_status_mappings_orderpro_idx (orderpro_status_code),
    CONSTRAINT order_status_mappings_integration_fk
        FOREIGN KEY (integration_id) REFERENCES integrations(id)
        ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
