Merge pull request #9824 from opf/fix/allow_reordering_without_db_constraints

remove db constraint on journals for reordering
pull/9826/head
Markus Kahl 3 years ago committed by GitHub
commit 3873529e19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      modules/costs/db/migrate/20210726065912_rename_cost_object_type.rb

@ -1,5 +1,9 @@
class RenameCostObjectType < ActiveRecord::Migration[6.1]
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
UPDATE
journals
@ -19,6 +23,8 @@ class RenameCostObjectType < ActiveRecord::Migration[6.1]
journals.journable_type = 'Budget'
SQL
add_index :journals, %i[journable_type journable_id version], unique: true
Journal
.where(journable_type: 'CostObject')
.update_all(journable_type: 'Budget')

Loading…
Cancel
Save