Skip to content

Commit c2cc5c4

Browse files
committed
fix(db): backfill existing super users to admin role in migration
Add UPDATE statement to promote is_super_user=true rows to role='admin' before dropping the is_super_user column, preventing silent demotion.
1 parent 95dde52 commit c2cc5c4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

packages/db/migrations/0177_wise_puma.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
ALTER TABLE "session" ADD COLUMN "impersonated_by" text;--> statement-breakpoint
22
ALTER TABLE "user" ADD COLUMN "role" text DEFAULT 'user';--> statement-breakpoint
3+
UPDATE "user" SET "role" = 'admin' WHERE "is_super_user" = true;--> statement-breakpoint
34
ALTER TABLE "user" ADD COLUMN "banned" boolean DEFAULT false;--> statement-breakpoint
45
ALTER TABLE "user" ADD COLUMN "ban_reason" text;--> statement-breakpoint
56
ALTER TABLE "user" ADD COLUMN "ban_expires" timestamp;--> statement-breakpoint

0 commit comments

Comments
 (0)