Fix remove code from promotions migration #3108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes two issues with the migration introduced into #3028.
Ref #2979
Please note that both issues are quite rare and we've found them by upgrading Solidus on very long-lived stores (previously on Spree).
I think it's better to backport these fixes into
v2.8
as well since the migration could fail and some custom change to it could be required.Promotions with type column set
spree_promotions
table used to be namedspree_activators
in legacy spree versions. This table was used by many models with STI via thetype
column. After that, it was renamed intospree_promotions
so having thistype
field does not make sense anymore.The issue here is that if you run this migration on stores that were created before the rename there will be that
type
field automatically set toSpree::Promotion
. This would raise an error while the migration runs:Promotions with empty string code (not nil)
code
field could be bothnil
and an empty string. If multiple empty string codes are present the migration would fail since it's not possible to have more than one code with an empty string in the database.Checklist: