|
|
@ -1,5 +1,9 @@ |
|
|
|
class RenameCostObjectType < ActiveRecord::Migration[6.1] |
|
|
|
class RenameCostObjectType < ActiveRecord::Migration[6.1] |
|
|
|
def up |
|
|
|
def up |
|
|
|
|
|
|
|
# Remove the index to allow duplicates for the time of the reordering. |
|
|
|
|
|
|
|
# It is recreated right afterwards. |
|
|
|
|
|
|
|
remove_index :journals, %i[journable_type journable_id version] |
|
|
|
|
|
|
|
|
|
|
|
execute <<~SQL.squish |
|
|
|
execute <<~SQL.squish |
|
|
|
UPDATE |
|
|
|
UPDATE |
|
|
|
journals |
|
|
|
journals |
|
|
@ -19,6 +23,8 @@ class RenameCostObjectType < ActiveRecord::Migration[6.1] |
|
|
|
journals.journable_type = 'Budget' |
|
|
|
journals.journable_type = 'Budget' |
|
|
|
SQL |
|
|
|
SQL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_index :journals, %i[journable_type journable_id version], unique: true |
|
|
|
|
|
|
|
|
|
|
|
Journal |
|
|
|
Journal |
|
|
|
.where(journable_type: 'CostObject') |
|
|
|
.where(journable_type: 'CostObject') |
|
|
|
.update_all(journable_type: 'Budget') |
|
|
|
.update_all(journable_type: 'Budget') |
|
|
|