Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null out the migrations from foreign key for script in section #35142

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class AddForeignKeyForScriptToSection < ActiveRecord::Migration[5.0]
def change
# This migration fails in production because it takes too long to apply (roughly 4 minutes).
# We need to add this if statement to skip running it in production so the next migration can revert it.
return if Rails.env.production?
add_foreign_key :sections, :scripts
# This migration failed in production because it takes too long to apply (roughly 4 minutes).
# We reverted it in RevertAddForeignKeyForScriptToSection. As clean up we are removing the
# content of this and the revert migrations.
# See https://github.com/code-dot-org/code-dot-org/pull/35088 for more details.
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@

class RevertAddForeignKeyForScriptToSection < ActiveRecord::Migration[5.0]
def change
# Original migration was never successfully applied to production,
# which is the reason we need to revert in the first place.
return if Rails.env.production?

revert AddForeignKeyForScriptToSection

# An index was implicitly added when foreign key constraint added, and rails doesn't know to delete it
# as part of the revert: https://github.com/rails/rails/issues/20048
remove_index :sections, name: :fk_rails_5c2401d1cb
# The AddForeignKeyForScriptToSection migration failed in production because it
# takes too long to apply (roughly 4 minutes). This reverted it. As clean up we
# are removing the content of this and the original migrations.
# See https://github.com/code-dot-org/code-dot-org/pull/35088 for more details.
end
end