-- Pack 18 support SQL

INSERT INTO settings (setting_key, setting_value)
VALUES
('warranty_reminder_days', '30'),
('branding_upload_dir', '/gopools/public/uploads/branding')
ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value);

ALTER TABLE users
    MODIFY COLUMN role ENUM('admin','manager','secretary','employee','partner','customer') NOT NULL DEFAULT 'employee';

CREATE TABLE IF NOT EXISTS project_edit_permissions (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    user_id INT UNSIGNED NOT NULL,
    project_id INT UNSIGNED NOT NULL,
    can_edit TINYINT(1) NOT NULL DEFAULT 1,
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY uq_project_edit_permissions (user_id, project_id),
    KEY idx_project_edit_permissions_user (user_id),
    KEY idx_project_edit_permissions_project (project_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
