Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'hotfix-0.36.2'
Browse files Browse the repository at this point in the history
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
FinnWoelm committed Feb 18, 2019
2 parents a7b0fe2 + b09b779 commit 0cd8192
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## v0.36.2 (Feb 18, 2019)

**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.

## v0.36.1 (Feb 18, 2019)

**Fixes:**
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class AddAcceptedRevisionToContributions < ActiveRecord::Migration[5.2]
def change
def up
add_reference :contributions, :accepted_revision,
foreign_key: { to_table: :vcs_commits }

Expand All @@ -11,7 +11,12 @@ def change
summary: contribution.description,
author_id: contribution.creator_id
)
contribution.update(accepted_revision: accepted_revision)
contribution.update_column(:accepted_revision_id,
accepted_revision&.id)
end
end

def down
remove_reference :contributions, :accepted_revision
end
end

0 comments on commit 0cd8192

Please sign in to comment.