-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4452 from Crown-Commercial-Service/update-migrati…
…on-to-unblock-higher-environments Update migration to avoid issue we have had on higher environments
- Loading branch information
Showing
2 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 17 additions & 4 deletions
21
db/migrate/20231031103327_rename_tables_with_long_names.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |