20170608151442_enhanced_permissions.rb 936 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class EnhancedPermissions < ActiveRecord::Migration[4.2]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. change_column_null :groups_users, :user_id, false
  7. change_column_null :groups_users, :group_id, false
  8. add_column :groups_users, :access, :string, limit: 50, null: false, default: 'full'
  9. add_index :groups_users, [:access]
  10. UserGroup.connection.schema_cache.clear!
  11. UserGroup.reset_column_information
  12. create_table :roles_groups, id: false do |t|
  13. t.references :role, null: false
  14. t.references :group, null: false
  15. t.string :access, limit: 50, null: false, default: 'full'
  16. end
  17. add_index :roles_groups, [:role_id]
  18. add_index :roles_groups, [:group_id]
  19. add_index :roles_groups, [:access]
  20. Rails.cache.clear
  21. end
  22. end