2017-09-08 08:28:34 +00:00
|
|
|
class EnhancedPermissions < ActiveRecord::Migration[4.2]
|
2017-06-16 20:43:09 +00:00
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
2020-08-03 08:35:43 +00:00
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
2017-06-16 20:43:09 +00:00
|
|
|
|
|
|
|
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
|
2020-06-22 09:57:45 +00:00
|
|
|
t.string :access, limit: 50, null: false, default: 'full'
|
2017-06-16 20:43:09 +00:00
|
|
|
end
|
|
|
|
add_index :roles_groups, [:role_id]
|
|
|
|
add_index :roles_groups, [:group_id]
|
|
|
|
add_index :roles_groups, [:access]
|
2017-06-19 06:21:07 +00:00
|
|
|
|
|
|
|
Cache.clear
|
2017-06-16 20:43:09 +00:00
|
|
|
end
|
|
|
|
end
|