Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit eee7a21

Browse files
bpamiriclaude
andcommitted
fix: Seed admin role permissions so admin can access all protected pages
The role_permissions junction table was empty - the admin role had no permissions granted despite permissions and roles being seeded. This migration grants the admin role access to all existing permissions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d02313e commit eee7a21

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
component extends="wheels.migrator.Migration" hint="seed admin role permissions" {
2+
3+
function up() {
4+
transaction {
5+
try {
6+
// Grant the admin role (id=1) access to ALL permissions
7+
execute("
8+
INSERT INTO role_permissions (role_id, permission_id, createdat, updatedat)
9+
SELECT 1, id, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
10+
FROM permissions
11+
WHERE id NOT IN (
12+
SELECT permission_id FROM role_permissions WHERE role_id = 1
13+
)
14+
");
15+
} catch (any e) {
16+
local.exception = e;
17+
}
18+
19+
if (StructKeyExists(local, "exception")) {
20+
transaction action="rollback";
21+
Throw(errorCode = "1", detail = local.exception.detail, message = local.exception.message, type = "any");
22+
} else {
23+
transaction action="commit";
24+
}
25+
}
26+
}
27+
28+
function down() {
29+
transaction {
30+
try {
31+
execute("DELETE FROM role_permissions WHERE role_id = 1");
32+
} catch (any e) {
33+
local.exception = e;
34+
}
35+
36+
if (StructKeyExists(local, "exception")) {
37+
transaction action="rollback";
38+
Throw(errorCode = "1", detail = local.exception.detail, message = local.exception.message, type = "any");
39+
} else {
40+
transaction action="commit";
41+
}
42+
}
43+
}
44+
45+
}

0 commit comments

Comments
 (0)