trabajo-afectivo/db/migrate/20170608151442_enhanced_permissions.rb

28 lines
930 B
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
2017-09-08 08:28:34 +00:00
class EnhancedPermissions < ActiveRecord::Migration[4.2]
def up
# return if it's a new setup
return if !Setting.exists?(name: 'system_init_done')
change_column_null :groups_users, :user_id, false
change_column_null :groups_users, :group_id, false
add_column :groups_users, :access, :string, limit: 50, null: false, default: 'full'
add_index :groups_users, [:access]
UserGroup.connection.schema_cache.clear!
UserGroup.reset_column_information
create_table :roles_groups, id: false do |t|
t.references :role, null: false
t.references :group, null: false
t.string :access, limit: 50, null: false, default: 'full'
end
add_index :roles_groups, [:role_id]
add_index :roles_groups, [:group_id]
add_index :roles_groups, [:access]
Cache.clear
end
end