Skip to content

Commit

Permalink
Update migration to avoid issue we have had on higher environments
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-s-ccs committed Jul 9, 2024
1 parent f08fc2d commit 946ee9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- FMFR-1399 - Use ccs frontend for the shared assets ([PR 4383](https:/Crown-Commercial-Service/crown-marketplace/pull/4383))
- FMFR-1398 - Use propshaft to build assets ([PR 4363](https:/Crown-Commercial-Service/crown-marketplace/pull/4363))

### Fixed

- Fix issue where higher environments would try to run old migration but could not ([PR 4452](https:/Crown-Commercial-Service/crown-marketplace/pull/4452))

### Security

- Various dependency updates
Expand Down
21 changes: 17 additions & 4 deletions db/migrate/20231031103327_rename_tables_with_long_names.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
class RenameTablesWithLongNames < ActiveRecord::Migration[7.1]
def change
rename_table :facilities_management_rm3830_procurement_building_service_lifts, :facilities_management_procurement_building_service_lifts
rename_table :facilities_management_rm3830_procurement_call_off_extensions, :facilities_management_rm3830_procurement_extensions
rename_table :facilities_management_rm6232_procurement_call_off_extensions, :facilities_management_rm6232_procurement_extensions
# We need to add this because we've had some issues on higher environments where it can't rename tables because of a primary key index name issue
# def change
# rename_table :facilities_management_rm3830_procurement_building_service_lifts, :facilities_management_procurement_building_service_lifts
# rename_table :facilities_management_rm3830_procurement_call_off_extensions, :facilities_management_rm3830_procurement_extensions
# rename_table :facilities_management_rm6232_procurement_call_off_extensions, :facilities_management_rm6232_procurement_extensions
# end

def up
ActiveRecord::Base.connection.exec_query('ALTER TABLE facilities_management_rm3830_procurement_building_service_lifts RENAME TO facilities_management_procurement_building_service_lifts;')
ActiveRecord::Base.connection.exec_query('ALTER TABLE facilities_management_rm3830_procurement_call_off_extensions RENAME TO facilities_management_rm3830_procurement_extensions;')
ActiveRecord::Base.connection.exec_query('ALTER TABLE facilities_management_rm6232_procurement_call_off_extensions RENAME TO facilities_management_rm6232_procurement_extensions;')
end

def down
ActiveRecord::Base.connection.exec_query('ALTER TABLE facilities_management_procurement_building_service_lifts RENAME TO facilities_management_rm3830_procurement_building_service_lifts;')
ActiveRecord::Base.connection.exec_query('ALTER TABLE facilities_management_rm3830_procurement_extensions RENAME TO facilities_management_rm3830_procurement_call_off_extensions;')
ActiveRecord::Base.connection.exec_query('ALTER TABLE facilities_management_rm6232_procurement_extensions RENAME TO facilities_management_rm6232_procurement_call_off_extensions;')
end
end

0 comments on commit 946ee9e

Please sign in to comment.