aviacommerce / avia

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

Handle error on duplicating product name #477

Closed Jeshan7 closed 5 years ago

Jeshan7 commented 5 years ago

Why?

Same product name was being entered for two different products. At DB level unique constraint is not for the name but, it is for the slug. This uniqueness constraint should be applicable for the products which are not deleted in the system, hence, uniqueness is now checked on a combination on slug name and deleted_at product field.

This change addresses the need by:

Created a unique_index on combination of slug and deleted_at in migrations. Added unique_constraint on slug and deleted_at in product.ex (schema)

[delivers #164069814]

Checklist

codecov[bot] commented 5 years ago

Codecov Report

Merging #477 into develop will increase coverage by 0.01%. The diff coverage is 75%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #477      +/-   ##
===========================================
+ Coverage    79.87%   79.89%   +0.01%     
===========================================
  Files          176      176              
  Lines         2216     2218       +2     
===========================================
+ Hits          1770     1772       +2     
  Misses         446      446
Impacted Files Coverage Δ
...core/lib/core/tools/elasticsearch/product/store.ex 36.84% <ø> (ø) :arrow_up:
apps/snitch_core/lib/core/data/model/product.ex 97.24% <ø> (ø) :arrow_up:
apps/snitch_core/lib/core/data/schema/product.ex 88.23% <75%> (+0.73%) :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 d33176c...edb346d. Read the comment docs.