Skip to content

Commit

Permalink
OAM-260: Added proper index cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pwargulak committed Aug 1, 2024
1 parent 6dd3d87 commit 72d5f58
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class StockCard extends BaseEntity implements IdentifiableByOrderableLotU
@Column
private UUID lotId;

@Column
@Column(nullable = false)
private UUID unitOfOrderableId;

@LazyCollection(FALSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class StockEventLineItem extends BaseEntity
@JoinColumn(name = "stockEventLineItemId")
private List<PhysicalInventoryLineItemAdjustment> stockAdjustments;

@Column(nullable = false)
private UUID unitOfOrderableId;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ public class PhysicalInventoryLineItem
implements VvmApplicable, IdentifiableByOrderableLotUnit {
@Column(nullable = false)
private UUID orderableId;

@Column
private UUID lotId;
@Column

@Column(nullable = false)
private UUID unitOfOrderableId;

//when saving draft quantity is allowed to be null
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Cleanup indexes
DROP INDEX IF EXISTS uniq_stock_card_facility_program_product_lot_unit;
DROP INDEX IF EXISTS uniq_stock_card_facility_program_product_lot;
DROP INDEX IF EXISTS uniq_stock_card_facility_program_product_unit;
DROP INDEX IF EXISTS uniq_stock_card_facility_program_product;

-- Create new indexes assuming unitOfOrderableId never null
CREATE UNIQUE INDEX uniq_stock_card_facility_program_product_lot_unit
ON stock_cards (facilityId, programId, orderableId, lotId, unitOfOrderableId) WHERE lotId IS NOT NULL;

CREATE UNIQUE INDEX uniq_stock_card_facility_program_product_unit
ON stock_cards (facilityId, programId, orderableId, unitOfOrderableId) WHERE lotId IS NULL;

0 comments on commit 72d5f58

Please sign in to comment.