summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20260731124136_add_roles_to_users.rb13
1 files changed, 13 insertions, 0 deletions
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 @@
1class AddRolesToUsers < ActiveRecord::Migration[8.1]
2 def up
3 add_column :users, :roles, :string, :array => true, :default => [], :null => false
4 execute "UPDATE users SET roles = ARRAY['admin','redaktion'] WHERE admin = true"
5 remove_column :users, :admin
6 end
7
8 def down
9 add_column :users, :admin, :boolean
10 execute "UPDATE users SET admin = true WHERE 'admin' = ANY(roles)"
11 remove_column :users, :roles
12 end
13end