<?php
declare(strict_types=1);

return [
    'up' => "
        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'role.view', NOW() FROM role_permissions WHERE permission_key = 'user.assign_role';

        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'role.create', NOW() FROM role_permissions WHERE permission_key = 'user.assign_role';

        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'role.edit', NOW() FROM role_permissions WHERE permission_key = 'user.assign_role';

        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'user.manage_permissions', NOW() FROM role_permissions WHERE permission_key = 'user.assign_role';

        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'member.pay_form_fee', NOW() FROM role_permissions WHERE permission_key = 'member.edit';

        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'member.pay_membership', NOW() FROM role_permissions WHERE permission_key = 'member.edit';

        INSERT IGNORE INTO role_permissions (role_id, permission_key, granted_at)
        SELECT role_id, 'member.fill_form', NOW() FROM role_permissions WHERE permission_key = 'member.edit';
    ",
    'down' => "
        DELETE FROM role_permissions WHERE permission_key IN (
            'role.view', 'role.create', 'role.edit', 'user.manage_permissions',
            'member.pay_form_fee', 'member.pay_membership', 'member.fill_form'
        )
    ",
];
