From 464dd4266bdc433805010b5dca428f4cb75c2a81 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 31 Jul 2026 15:55:43 +0200 Subject: Group user accounts by role Replaces the two-way admin/user split with four groups ordered by capability: administration, Redaktion, editors, alumni. alumni takes precedence over capability in role_group, so a retired admin appears at the bottom rather than the top. Forms now offer the three roles as checkboxes rather than a single admin checkbox, with a trailing hidden blank so an empty set can be posted, and user_params permits roles only for admins. Three create buttons prefill the common combinations. --- db/migrate/20260731124136_add_roles_to_users.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/migrate/20260731124136_add_roles_to_users.rb (limited to 'db/migrate') diff --git a/db/migrate/20260731124136_add_roles_to_users.rb b/db/migrate/20260731124136_add_roles_to_users.rb new file mode 100644 index 00000000..ea003e60 --- /dev/null +++ b/db/migrate/20260731124136_add_roles_to_users.rb @@ -0,0 +1,13 @@ +class AddRolesToUsers < ActiveRecord::Migration[8.1] + def up + add_column :users, :roles, :string, :array => true, :default => [], :null => false + execute "UPDATE users SET roles = ARRAY['admin','redaktion'] WHERE admin = true" + remove_column :users, :admin + end + + def down + add_column :users, :admin, :boolean + execute "UPDATE users SET admin = true WHERE 'admin' = ANY(roles)" + remove_column :users, :roles + end +end -- cgit v1.3