<?php
declare(strict_types=1);

return [
    'up' => "
        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT rp.role_id, CONCAT('forms.access.', fs.form_code), NOW()
        FROM role_permissions rp
        CROSS JOIN form_schemas fs
        WHERE rp.permission_key = 'forms.view'
          AND fs.is_active = 1
    ",
    'down' => "
        DELETE FROM role_permissions WHERE permission_key LIKE 'forms.access.%'
    ",
];
