gohorsejobs/backend/migrations/022_fix_superadmin_role.sql

10 lines
490 B
SQL

-- Migration: Fix Super Admin Role
-- Description: Ensures superadmin has the 'superadmin' role in user_roles table.
-- Needed because 010 ran before 020 (which created the table).
INSERT INTO user_roles (user_id, role)
SELECT id, 'superadmin' FROM users WHERE identifier = 'superadmin'
ON CONFLICT (user_id, role) DO NOTHING;
-- Also ensure seeded admins have their roles if they were missed
-- (Though they are likely handled by seeder script running AFTER migrations, but safe to add)