Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/api/drizzle/0037_nullable_catalog_weight.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- catalog_items.weight and weight_unit: drop NOT NULL to allow items without weight data.
-- The validator intentionally skips weight (clothing/footwear often omit it), but the
-- NOT NULL constraint was causing upserts to throw, which cascaded to ETL job failures.
ALTER TABLE "catalog_items" ALTER COLUMN "weight" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "catalog_items" ALTER COLUMN "weight_unit" DROP NOT NULL;
Comment on lines +1 to +5

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove the duplicate 0037 migration file to avoid drift/confusion.

This file duplicates the 0037_rich_electro DDL while the journal tracks 0037_rich_electro. Keeping both increases the risk of future divergence during migration maintenance.

🧹 Suggested cleanup
--- a/packages/api/drizzle/0037_nullable_catalog_weight.sql
+++ /dev/null
@@
--- catalog_items.weight and weight_unit: drop NOT NULL to allow items without weight data.
--- The validator intentionally skips weight (clothing/footwear often omit it), but the
--- NOT NULL constraint was causing upserts to throw, which cascaded to ETL job failures.
-ALTER TABLE "catalog_items" ALTER COLUMN "weight" DROP NOT NULL;--> statement-breakpoint
-ALTER TABLE "catalog_items" ALTER COLUMN "weight_unit" DROP NOT NULL;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
-- catalog_items.weight and weight_unit: drop NOT NULL to allow items without weight data.
-- The validator intentionally skips weight (clothing/footwear often omit it), but the
-- NOT NULL constraint was causing upserts to throw, which cascaded to ETL job failures.
ALTER TABLE "catalog_items" ALTER COLUMN "weight" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "catalog_items" ALTER COLUMN "weight_unit" DROP NOT NULL;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/api/drizzle/0037_nullable_catalog_weight.sql` around lines 1 - 5,
Delete this duplicate migration file that applies ALTER TABLE "catalog_items"
ALTER COLUMN "weight" DROP NOT NULL and ALTER COLUMN "weight_unit" DROP NOT NULL
and keep the canonical 0037_rich_electro migration tracked by the journal;
remove the duplicate 0037 nullable catalog migration from the repository, ensure
the migration journal still references only 0037_rich_electro, and run the
migration tests (or a dry-run) to confirm no drift remains.

2 changes: 2 additions & 0 deletions packages/api/drizzle/0037_rich_electro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "catalog_items" ALTER COLUMN "weight" DROP NOT NULL;--> statement-breakpoint
ALTER TABLE "catalog_items" ALTER COLUMN "weight_unit" DROP NOT NULL;
Loading
Loading