Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema update #80

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions dirs/ecommerce/migrations/20240820130921.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "product_reviews" table
ALTER TABLE `product_reviews` ADD UNIQUE INDEX `user_product_review` (`user_id`, `product_id`);

Check warning on line 2 in dirs/ecommerce/migrations/20240820130921.sql

View workflow job for this annotation

GitHub Actions / atlas

data dependent changes detected

Adding a unique index "user_product_review" on table "product_reviews" might fail in case columns "user_id", "product_id" contain duplicate entries (MF101) Details: https://atlasgo.io/lint/analyzers#MF101
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:t5nB6GHWoQqI+kJDICV6tBKGpotim6b5wphogskPQlQ=
h1:2o9wb+D492kEsRX8rG06tnSTdP5U3MNXlgxJ/JbZ4BQ=
20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo=
20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY=
20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA=
Expand Down Expand Up @@ -35,3 +35,4 @@ h1:t5nB6GHWoQqI+kJDICV6tBKGpotim6b5wphogskPQlQ=
20240808130858.sql h1:z1ZMAu6Olrqut5mavBk5M9CbJ0Yb7Calp9vSMyFJEvY=
20240811130749.sql h1:gdDmY5C1ZLsdBT6BSYnwlub1rFzYPtsP4gZdrXpRfRI=
20240815125449.sql h1:3vhjuCKKwckYQX7JIEFDL6hfjoiHFD5iECEmgfdvcHI=
20240820130921.sql h1:jI1wgEMLFJ90gSqeQLR1y5PSCWnWX+lmwAE8WXy4Nws=
3 changes: 2 additions & 1 deletion dirs/ecommerce/schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Create 'users' table
-- Create 'users' table
CREATE TABLE `users` (
`id` int NOT NULL,
`user_name` varchar(255) NOT NULL,
Expand Down Expand Up @@ -52,6 +52,7 @@ CREATE TABLE `product_reviews` (
PRIMARY KEY (`id`),
INDEX `product_id` (`product_id`),
INDEX `user_id` (`user_id`),
UNIQUE INDEX `user_product_review` (`user_id`, `product_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,
CHECK (`rating` BETWEEN 1 AND 5)
Expand Down
Loading