aviacommerce / avia

open source e-commerce framework
https://aviacommerce.netlify.app/
MIT License
529 stars 113 forks source link

User deletion #451

Closed jyotigautam closed 5 years ago

jyotigautam commented 5 years ago

Why?

To allow user deletion in the system.

This change addresses the need by:

  1. Adding state (active or deleted) and deleted_at field to user and allowing soft deletion of user.
  2. Add unique index to user email and deleted_at field in user schema.

Migration added: apps/snitch_core/priv/repo/migrations/20190128081011_update_user_unique_index.exs

Referred blog: Make soft deleted user email available again

delivers #163182381

Checklist

codecov[bot] commented 5 years ago

Codecov Report

Merging #451 into develop will increase coverage by 0.13%. The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #451      +/-   ##
===========================================
+ Coverage    77.73%   77.86%   +0.13%     
===========================================
  Files          174      174              
  Lines         2120     2128       +8     
===========================================
+ Hits          1648     1657       +9     
+ Misses         472      471       -1
Impacted Files Coverage Δ
...pps/snitch_core/lib/core/domain/account/account.ex 100% <ø> (ø) :arrow_up:
apps/snitch_core/lib/core/data/model/user.ex 100% <100%> (+11.11%) :arrow_up:
apps/snitch_core/lib/core/data/schema/user.ex 100% <100%> (ø) :arrow_up:
...nitch_core/lib/core/tools/ecto_enums/ecto_enums.ex 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d0cd636...1f5944e. Read the comment docs.

ashish173 commented 5 years ago

@jyotigautam There are some cases we need to test for user model.

  1. The scenario where we create -> delete a user -> create again with same email = result should be two different user records with the same email but only the active user is returned in model functions.