20170608151442_enhanced_permissions.rb 859 B

12345678910111213141516171819202122232425
  1. class EnhancedPermissions < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. change_column_null :groups_users, :user_id, false
  6. change_column_null :groups_users, :group_id, false
  7. add_column :groups_users, :access, :string, limit: 50, null: false, default: 'full'
  8. add_index :groups_users, [:access]
  9. UserGroup.connection.schema_cache.clear!
  10. UserGroup.reset_column_information
  11. create_table :roles_groups, id: false do |t|
  12. t.references :role, null: false
  13. t.references :group, null: false
  14. t.string :access, limit: 50, null: false, default: 'full'
  15. end
  16. add_index :roles_groups, [:role_id]
  17. add_index :roles_groups, [:group_id]
  18. add_index :roles_groups, [:access]
  19. Cache.clear
  20. end
  21. end