Improved migration.
This commit is contained in:
parent
714cede3e2
commit
7d76805f98
1 changed files with 13 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
class OutOfOffice < ActiveRecord::Migration[4.2]
|
class OutOfOffice2 < ActiveRecord::Migration[4.2]
|
||||||
def up
|
def up
|
||||||
|
|
||||||
# return if it's a new setup
|
# return if it's a new setup
|
||||||
|
@ -9,6 +9,18 @@ class OutOfOffice < ActiveRecord::Migration[4.2]
|
||||||
Overview.reset_column_information
|
Overview.reset_column_information
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !ActiveRecord::Base.connection.column_exists?(:users, :out_of_office)
|
||||||
|
add_column :users, :out_of_office, :boolean, null: false, default: false
|
||||||
|
add_column :users, :out_of_office_start_at, :date, null: true
|
||||||
|
add_column :users, :out_of_office_end_at, :date, null: true
|
||||||
|
add_column :users, :out_of_office_replacement_id, :integer, null: true
|
||||||
|
|
||||||
|
add_index :users, [:out_of_office, :out_of_office_start_at, :out_of_office_end_at], name: 'index_out_of_office'
|
||||||
|
add_index :users, [:out_of_office_replacement_id]
|
||||||
|
add_foreign_key :users, :users, column: :out_of_office_replacement_id
|
||||||
|
User.reset_column_information
|
||||||
|
end
|
||||||
|
|
||||||
role_ids = Role.with_permissions(['ticket.agent']).map(&:id)
|
role_ids = Role.with_permissions(['ticket.agent']).map(&:id)
|
||||||
overview_role = Role.find_by(name: 'Agent')
|
overview_role = Role.find_by(name: 'Agent')
|
||||||
Overview.create_or_update(
|
Overview.create_or_update(
|
||||||
|
@ -41,18 +53,6 @@ class OutOfOffice < ActiveRecord::Migration[4.2]
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
if !ActiveRecord::Base.connection.column_exists?(:users, :out_of_office)
|
|
||||||
add_column :users, :out_of_office, :boolean, null: false, default: false
|
|
||||||
add_column :users, :out_of_office_start_at, :date, null: true
|
|
||||||
add_column :users, :out_of_office_end_at, :date, null: true
|
|
||||||
add_column :users, :out_of_office_replacement_id, :integer, null: true
|
|
||||||
|
|
||||||
add_index :users, [:out_of_office, :out_of_office_start_at, :out_of_office_end_at], name: 'index_out_of_office'
|
|
||||||
add_index :users, [:out_of_office_replacement_id]
|
|
||||||
add_foreign_key :users, :users, column: :out_of_office_replacement_id
|
|
||||||
User.reset_column_information
|
|
||||||
end
|
|
||||||
|
|
||||||
Cache.clear
|
Cache.clear
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue