diff --git a/dirs/ecommerce/migrations/20241114131226.sql b/dirs/ecommerce/migrations/20241114131226.sql new file mode 100644 index 0000000..52b5e5a --- /dev/null +++ b/dirs/ecommerce/migrations/20241114131226.sql @@ -0,0 +1,2 @@ +-- Modify "inventory" table +ALTER TABLE `inventory` ADD CONSTRAINT `inventory_chk_1` CHECK (`quantity` >= 0); diff --git a/dirs/ecommerce/migrations/atlas.sum b/dirs/ecommerce/migrations/atlas.sum index 11320e0..5e69258 100644 --- a/dirs/ecommerce/migrations/atlas.sum +++ b/dirs/ecommerce/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:mQ4os5dvdZVxq9ucRsiEYty95umfc04MMDQfT68e+VI= +h1:NpEy8HM4ZGHgJAWhU65tAJQPaSHCaaEipRBHfZzkY64= 20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo= 20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY= 20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA= @@ -59,3 +59,4 @@ h1:mQ4os5dvdZVxq9ucRsiEYty95umfc04MMDQfT68e+VI= 20241105131055.sql h1:Pa43oRSXYgYlTyRPmz+ifOUdjC37MBxXty/y6GLCaqk= 20241107131023.sql h1:ZCiG0I6S1KZRirv89U4894V9ZBuG6ChLYDuPyWC098c= 20241110130904.sql h1:qRQ+S6KPxiFyp8VxRMkZIFVop3rO1qrS3EJpKz2gjhw= +20241114131226.sql h1:kQjVyuZaEewk+qpzGzSpj2Pwm6mJ6XWci4kBCXXdIY0= diff --git a/dirs/ecommerce/schema.sql b/dirs/ecommerce/schema.sql index b28a8c0..2259bab 100644 --- a/dirs/ecommerce/schema.sql +++ b/dirs/ecommerce/schema.sql @@ -88,7 +88,8 @@ CREATE TABLE `inventory` ( INDEX `fulfillment_center_id` (`fulfillment_center_id`), INDEX `product_id` (`product_id`), CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, - CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`fulfillment_center_id`) REFERENCES `fulfillment_centers` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE + CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`fulfillment_center_id`) REFERENCES `fulfillment_centers` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE, + CHECK (`quantity` >= 0) ) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT 'Table for managing inventory levels of products at various fulfillment centers'; -- Create 'orders' table