This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hotfix v0.36.2: Fix contribution migrations **Fixes:** - Use `#update` to `#update_column` in new migrations to avoid validations. Otherwise, the validations will fail because some of the columns that are are referenced by the validations will only be added in later migrations.
- Loading branch information
Showing
3 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
9 changes: 7 additions & 2 deletions
9
db/migrate/20190215234419_add_origin_revision_to_contributions.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,13 +1,18 @@ | ||
class AddOriginRevisionToContributions < ActiveRecord::Migration[5.2] | ||
def change | ||
def up | ||
add_reference :contributions, :origin_revision, | ||
foreign_key: { to_table: :vcs_commits } | ||
|
||
Contribution.reset_column_information | ||
Contribution.includes(:project).find_each do |contribution| | ||
contribution.update(origin_revision: contribution.project.revisions.last) | ||
contribution.update_column(:origin_revision_id, | ||
contribution.project.revisions.last&.id) | ||
end | ||
|
||
change_column_null :contributions, :origin_revision_id, false | ||
end | ||
|
||
def down | ||
remove_reference :contributions, :origin_revision | ||
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