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

Commit 0cd8192

Browse files
committed
Merge branch 'hotfix-0.36.2'
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.
2 parents a7b0fe2 + b09b779 commit 0cd8192

3 files changed

+21
-4
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## v0.36.2 (Feb 18, 2019)
4+
5+
**Fixes:**
6+
- Use `#update` to `#update_column` in new migrations to avoid validations.
7+
Otherwise, the validations will fail because some of the columns that are
8+
are referenced by the validations will only be added in later migrations.
9+
310
## v0.36.1 (Feb 18, 2019)
411

512
**Fixes:**
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
class AddOriginRevisionToContributions < ActiveRecord::Migration[5.2]
2-
def change
2+
def up
33
add_reference :contributions, :origin_revision,
44
foreign_key: { to_table: :vcs_commits }
55

66
Contribution.reset_column_information
77
Contribution.includes(:project).find_each do |contribution|
8-
contribution.update(origin_revision: contribution.project.revisions.last)
8+
contribution.update_column(:origin_revision_id,
9+
contribution.project.revisions.last&.id)
910
end
1011

1112
change_column_null :contributions, :origin_revision_id, false
1213
end
14+
15+
def down
16+
remove_reference :contributions, :origin_revision
17+
end
1318
end

db/migrate/20190217040248_add_accepted_revision_to_contributions.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class AddAcceptedRevisionToContributions < ActiveRecord::Migration[5.2]
2-
def change
2+
def up
33
add_reference :contributions, :accepted_revision,
44
foreign_key: { to_table: :vcs_commits }
55

@@ -11,7 +11,12 @@ def change
1111
summary: contribution.description,
1212
author_id: contribution.creator_id
1313
)
14-
contribution.update(accepted_revision: accepted_revision)
14+
contribution.update_column(:accepted_revision_id,
15+
accepted_revision&.id)
1516
end
1617
end
18+
19+
def down
20+
remove_reference :contributions, :accepted_revision
21+
end
1722
end

0 commit comments

Comments
 (0)