-- Pack 22.5 – Final Role Permissions + Partner Costing

CREATE TABLE IF NOT EXISTS partner_project_costings (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    project_id INT UNSIGNED NOT NULL,
    external_partner_id INT UNSIGNED NOT NULL,
    submitted_by_user_id INT UNSIGNED NULL,
    quote_amount DECIMAL(12,2) NOT NULL DEFAULT 0,
    notes TEXT NULL,
    status ENUM('draft','submitted','approved') NOT NULL DEFAULT 'submitted',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY uq_partner_project_costings (project_id, external_partner_id),
    KEY idx_partner_project_costings_project (project_id),
    KEY idx_partner_project_costings_partner (external_partner_id),
    KEY idx_partner_project_costings_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
