Skip to content

Commit

Permalink
Added CHECK constraint to ensure the 'rating' field in the 'product_r…
Browse files Browse the repository at this point in the history
…eviews' table is between 1 and 5. (#78)

Co-authored-by: GitHub Gen Changes <>
  • Loading branch information
ariga-bot authored Aug 11, 2024
1 parent c6f9114 commit c4de4de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions dirs/ecommerce/migrations/20240811130749.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "product_reviews" table
ALTER TABLE `product_reviews` ADD CONSTRAINT `product_reviews_chk_1` CHECK (`rating` between 1 and 5);
3 changes: 2 additions & 1 deletion dirs/ecommerce/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:806odcq2F5kkRaJYwq2nosWuoruvz8C5bYCzQRtiLuc=
h1:kz7N16b5Eatu6BuQPfx9lB5yLf7L3dDPAg6Z0Cu9Jlk=
20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo=
20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY=
20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA=
Expand Down Expand Up @@ -33,3 +33,4 @@ h1:806odcq2F5kkRaJYwq2nosWuoruvz8C5bYCzQRtiLuc=
20240804130742.sql h1:kB1qxstPuROcCPaWyqXh0ZnjpBsOSxGRLQJTa+CP03w=
20240806130855.sql h1:rsSJMFdmgp33FVqqG5ONW+F8tv3+x1D2xEn+ATwNJw0=
20240808130858.sql h1:z1ZMAu6Olrqut5mavBk5M9CbJ0Yb7Calp9vSMyFJEvY=
20240811130749.sql h1:gdDmY5C1ZLsdBT6BSYnwlub1rFzYPtsP4gZdrXpRfRI=
3 changes: 2 additions & 1 deletion dirs/ecommerce/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ PRIMARY KEY (`id`),
INDEX `product_id` (`product_id`),
INDEX `user_id` (`user_id`),
CONSTRAINT `product_reviews_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT `product_reviews_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
CONSTRAINT `product_reviews_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
CHECK (`rating` BETWEEN 1 AND 5)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create 'fulfillment_centers' table
Expand Down

0 comments on commit c4de4de

Please sign in to comment.