Skip to content

Commit

Permalink
Merge pull request #439 from alphagov/cleanup-country-columns-again
Browse files Browse the repository at this point in the history
Cleanup country columns again
  • Loading branch information
pixeltrix committed Feb 21, 2016
2 parents 63859fc + 175f1f2 commit 46661c3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions db/migrate/20160214133749_cleanup_country_columns.rb
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
2 changes: 1 addition & 1 deletion db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ INSERT INTO schema_migrations (version) VALUES ('20160211002731');

INSERT INTO schema_migrations (version) VALUES ('20160211003703');

INSERT INTO schema_migrations (version) VALUES ('20160211020341');
INSERT INTO schema_migrations (version) VALUES ('20160214133749');

INSERT INTO schema_migrations (version) VALUES ('20160214233414');

Expand Down

0 comments on commit 46661c3

Please sign in to comment.