- Bumped application version to 0.8.20 in both backend and frontend files. - Introduced migration 041 to promote the oldest admin user to superadmin if no superadmin exists. - Updated registration logic to assign the superadmin role to the first user and those in ADMIN_BOOTSTRAP_EMAILS. - Enhanced changelog to document the new version and changes made in this release.
21 lines
635 B
SQL
21 lines
635 B
SQL
-- Migration 041: Super-Admin für bestehende Installationen
|
|
-- Bisheriger Bootstrap (registration_role) setzte nur 'admin'. Viele Endpunkte
|
|
-- (z. B. Verein löschen, Super-Rolle vergeben) verlangen 'superadmin'.
|
|
-- Wenn noch kein Super-Admin existiert: den ältesten Nutzer mit role = admin hochstufen.
|
|
|
|
UPDATE profiles p
|
|
SET role = 'superadmin', updated_at = NOW()
|
|
FROM (
|
|
SELECT id
|
|
FROM profiles
|
|
WHERE lower(trim(COALESCE(role, ''))) = 'admin'
|
|
ORDER BY id ASC
|
|
LIMIT 1
|
|
) sub
|
|
WHERE p.id = sub.id
|
|
AND NOT EXISTS (
|
|
SELECT 1
|
|
FROM profiles
|
|
WHERE lower(trim(COALESCE(role, ''))) = 'superadmin'
|
|
);
|