-- Pack 20 support SQL
-- Safe for old MySQL versions if the table does not already exist.

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;
