-
Notifications
You must be signed in to change notification settings - Fork 77
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 #439 from alphagov/cleanup-country-columns-again
Cleanup country columns again
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class CleanupCountryColumns < ActiveRecord::Migration | ||
def up | ||
# This migration commands have guard clauses because the preview | ||
# website executed a migration that was subsequently deleted | ||
# because of performance problems with it. Therefore to ensure | ||
# that the runs successfully on preview it needs these clauses. | ||
|
||
if index_exists?(:country_petition_journals, [:petition_id, :country]) | ||
remove_index :country_petition_journals, [:petition_id, :country] | ||
end | ||
|
||
if column_exists?(:country_petition_journals, :country) | ||
remove_column :country_petition_journals, :country | ||
end | ||
|
||
if column_exists?(:signatures, :country) | ||
remove_column :signatures, :country | ||
end | ||
end | ||
|
||
def down | ||
add_column :signatures, :country, :string | ||
add_column :country_petition_journals, :country, :string | ||
add_index :country_petition_journals, [:petition_id, :country], unique: true | ||
end | ||
end |
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