From 46e2ee3d7b8f128e33a47305db7561c30f7d1c12 Mon Sep 17 00:00:00 2001 From: Jake Kasper Date: Wed, 3 Sep 2025 12:02:27 -0400 Subject: [PATCH] database for seed --- ...__expand_user_products_custom_product_type.sql | 15 +++++++++++++++ frontend/src/pages/Admin/AdminProducts.js | 12 ++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 database/migrations/V6__expand_user_products_custom_product_type.sql diff --git a/database/migrations/V6__expand_user_products_custom_product_type.sql b/database/migrations/V6__expand_user_products_custom_product_type.sql new file mode 100644 index 0000000..e9ad88d --- /dev/null +++ b/database/migrations/V6__expand_user_products_custom_product_type.sql @@ -0,0 +1,15 @@ +-- Expand allowed values for user_products.custom_product_type to include seed and powder +DO $$ +DECLARE cname text; +BEGIN + SELECT conname INTO cname + FROM pg_constraint + WHERE conrelid = 'user_products'::regclass AND contype='c' AND conname LIKE '%custom_product_type%'; + IF cname IS NOT NULL THEN + EXECUTE format('ALTER TABLE user_products DROP CONSTRAINT %I', cname); + END IF; +END $$; + +ALTER TABLE user_products + ADD CONSTRAINT user_products_custom_product_type_check CHECK (custom_product_type IN ('granular','liquid','seed','powder')); + diff --git a/frontend/src/pages/Admin/AdminProducts.js b/frontend/src/pages/Admin/AdminProducts.js index 58158e6..2251959 100644 --- a/frontend/src/pages/Admin/AdminProducts.js +++ b/frontend/src/pages/Admin/AdminProducts.js @@ -543,7 +543,7 @@ const AdminProducts = () => { - {loading ? ( + {loading && !showCreateModal && !showEditModal && !showDetailsModal && !showDeleteModal ? (
@@ -596,10 +596,14 @@ const AdminProducts = () => { {product.productType}