Remove Spree::UserAddress#archived flag#3852
Conversation
core/db/migrate/20201201170826_remove_archived_user_addresses.rb
Outdated
Show resolved
Hide resolved
7ccde24 to
1905a7e
Compare
kennyadsl
left a comment
There was a problem hiding this comment.
@mamhoff thanks!
I think that your reasoning makes total sense, it took me a while to get it only reading the PR description because of a mistake:
Why not remove the join table entry directly?
Should be
Why not remove the record from the join table entry directly?
I think that fixing it could help readers from the future to avoid confusion.
In terms of PR's content, I also can't find a reason not to remove the record, instead of resurrecting an old one but I think we should deprecate the usage of archived instead of removing the column, which in my opinion is too invasive and gives for granted that people are not using that field with some custom code.
I also considered using Discard (which at least would be consistent with the rest of the code) + remove the "resurrecting" logic but honestly, I'd avoid it here since it's just a record on a join table and I can't see any point where we may have some value in soft-deleting.
1905a7e to
2323468
Compare
|
Rebased this PR on the current |
|
@kennyadsl I changed the wording of the commit message. I've also kept the scopes to return all records instead of their custom behavior. If stores make use of that |
af03ace to
86ec7d0
Compare
|
From @kennyadsl : Check if default billing / default shipping addresses are preserved with this change |
225e964 to
9ae594a
Compare
|
@mamhoff looks good but I don't understand why the commit states "Behavior change". I'm not sure to follow which behavior changed. Are you saying that at the moment, when we are "changing" an address that was set as the default, the resulting new immutable address won't have the default (ship or bill) boolean set? If yes, this is probably worth a separate PR? |
|
Yes, i think that is what happens :) I'll provide a separate PR |
0d1d4d7 to
cf90855
Compare
|
@kennyadsl Extracted the behavior change to #4332, care to re-review? :) |
core/db/migrate/20201201170826_remove_archived_user_addresses.rb
Outdated
Show resolved
Hide resolved
|
|
||
| class RemoveArchivedUserAddresses < ActiveRecord::Migration[5.2] | ||
| def up | ||
| Spree::UserAddress.where(archived: true).delete_all |
There was a problem hiding this comment.
I'm still a little bit scared about this. We are assuming people are only using this field in the way we think but it's not guaranteed.
Maybe we can keep the archived column (ignoring it on the Rails side) and use the bin/rails g solidus:update task to be sure people are understanding that those records will be deleted from their database. What do you think?
There was a problem hiding this comment.
@waiting-for-dev correct me if I'm wrong here, but if I recall correctly it's a matter of adding a new method in the update generator, isn't it?
There was a problem hiding this comment.
I really can't imagine that - and if we leave the field, we'll have to deal with it in every upgrade from now on (similar to the Spree::Shipment#deprecated_address_id field. I'd rather add a large changelog entry, and be done with it. People who use the archived flag for something will still be able to edit the migration on their project to not delete the records / column.
There was a problem hiding this comment.
Using ignored_columns I think it will be pretty transparent for us.
In my opinion, it's not a matter of imagining how the feature could be used, but more of a formal process of making this software as compliant with SemVer as possible. And removing a table column in a minor release is definitely a breaking change from all possible points of view.
For Spree::Shipment#deprecated_address_id (#4333), it is a bit different because we are not using that field in the code from 2016 as you mentioned in the PR, so it's very unlikely that it is being used. BTW, I think that PR should go in a major release as well. I didn't comment because I just missed it. 🙂
There was a problem hiding this comment.
@waiting-for-dev correct me if I'm wrong here, but if I recall correctly it's a matter of adding a new method in the update generator, isn't it?
Do you mean adding a message? Yes, we could do that by adding a new method. However, the actual code is already redirecting people to the Changelog. I think it'd be better to add any information there and keep using it as the unique source of truth for upgrades info.
There was a problem hiding this comment.
Basically, this way we won't have to remember removing the new message before the next Solidus version 😉
cf90855 to
f6c3e38
Compare
tvdeyen
left a comment
There was a problem hiding this comment.
I think we should be less strict on semver with this change, because this change has never been visible to users and or admins. It is completely hidden from any UI. We even do not have an address book UI. The only potential users of this "feature" would have been developers and or data analysts. But I bet this is not used by anyone. This causes a lot of confusion and complex code.
What this does is, that it mimics discard where it is not necessary, because addresses are not actually removed, but just removed from the users addresses. This causes lots of confusion.
We recently migrated a store from spree to solidus and were very confused still seeing deleted addresses in the users address books.
I am for removing this even in a minor version. 👍🏻
|
I'm ok removing the feature entirely in a minor version. Just saying that maybe we can postpone the database column removal to the next major by just using On the other hand, when I will bring this to the core team meeting later today and will get back with a shared decision. Thanks again! |
If we use |
|
With By the way, even if it's just that, it's not less complex than manually changing the migration so that nothing happens. |
|
As is, I'd push this as well in the next major. Since it's not that far I think it's a good idea to avoid removing columns from the database in a minor. |
00bfb41 to
3a5064a
Compare
ea45854 to
2210e19
Compare
|
Rebased fromn |
| ## Solidus 1.0.0 (2015-08-11) | ||
|
|
||
| See https://github.com/solidusio/solidus/releases/tag/v1.0.0 No newline at end of file | ||
| See https://github.com/solidusio/solidus/releases/tag/v1.0.0 |
There was a problem hiding this comment.
Non-blocking, but ideally, we shouldn't have any diff with the Changelog.
2210e19 to
5185400
Compare
|
Again, sorry for raising this only now, but we were thinking about alternative paths to deprecate removing this column. We were thinking about this approach but we are not 100 sure it's the best approach yet. Leaving here for documentation. In the first minor:
In a subsequent minor (to be sure that code has been deployed):
On the next major, we can remove deprecated code and the column safely. |
|
@kennyadsl I strongly believe that this is good as is. Not necessary to add deprecations for imo. This is a pressing issue and it has been pushed back for too long now. |
This flag is not very useful and gives rise to bugs. It is not very useful, as we only need it to "resurrect" addresses that the user inputs newly, but that match an address that has been removed from the address book in the past for some reason. Why not remove the record from the join table directly? Much simpler, and less code to worry about. The bug we found that exists only because of the existence of this column is the following: If an address is added to the address book that matches an existing user address that is archived, there is a chance of it throwing a uniqueness validation error, because the uniqueness check on user/address on the Spree::UserAddress model does not take into account the "archived" flag. The third reason why I think this should go is for data protection reasons: If I call "delete" on a record, I want it to be gone, not half-gone. And in the case of a join table representing which addresses a user wants to be presented with again, I very much want it gone. Not archived. Note also: Removing this complexity removes explanatory comments in otherwise straight-forward API endpoints.
5185400 to
6fc2564
Compare
Done! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3852 +/- ##
==========================================
- Coverage 88.70% 88.67% -0.03%
==========================================
Files 829 829
Lines 17992 17995 +3
==========================================
- Hits 15959 15957 -2
- Misses 2033 2038 +5 ☔ View full report in Codecov by Sentry. |
|
🎉 💯 |
Description
This flag is not very useful and gives rise to bugs.
It is not very useful, as we only need it to "resurrect" addresses that
the user inputs newly, but that match an address that has been removed
from the address book in the past for some reason. Why not remove the
join table entry directly? Much simpler, and less code to worry about.
The bug we found that exists only because of the existence of this
column is the following: If an address is added to the address book that
matches an existing user address that is archived, there is a chance of
it throwing a uniqueness validation error, because the uniqueness check
on user/address on the Spree::UserAddress model does not take into
account the "archived" flag.
The third reason why I think this should go is for data protection
reasons: If I call "delete" on a record, I want it to be gone, not
half-gone. And in the case of a join table representing which addresses
a user wants to be presented with again, I very much want it gone.
Not archived.
Note also: Removing this complexity removes explanatory comments in
otherwise straight-forward API endpoints.
Checklist:
addedremoved tests to cover this change