diff --git a/backend/src/main/resources/db/migration/V59__seed_blog_write.sql b/backend/src/main/resources/db/migration/V59__seed_blog_write.sql new file mode 100644 index 00000000..b653072a --- /dev/null +++ b/backend/src/main/resources/db/migration/V59__seed_blog_write.sql @@ -0,0 +1,16 @@ +-- Grant BLOG_WRITE to every existing group that already holds WRITE_ALL. +-- Without this, the Geschichten feature ships dark to production: no group +-- has BLOG_WRITE, so the editor controls are invisible and "+ Neue Geschichte" +-- is never rendered. The natural mapping is "groups that can already write +-- documents and tags can also author family stories." Admins can revoke or +-- re-assign via the group editor afterwards. + +INSERT INTO group_permissions (group_id, permission) +SELECT DISTINCT gp.group_id, 'BLOG_WRITE' +FROM group_permissions gp +WHERE gp.permission = 'WRITE_ALL' + AND NOT EXISTS ( + SELECT 1 FROM group_permissions existing + WHERE existing.group_id = gp.group_id + AND existing.permission = 'BLOG_WRITE' + );