From 9339ad40c0a507502968af4d57820a15f1c9491f Mon Sep 17 00:00:00 2001 From: GitHub Gen Changes <> Date: Sun, 14 Jul 2024 13:21:23 +0000 Subject: [PATCH] Added a unique constraint on the 'email' column in the 'users' table to ensure that each user has a unique email address. --- dirs/ecommerce/migrations/20240714132123.sql | 2 ++ dirs/ecommerce/migrations/atlas.sum | 3 ++- dirs/ecommerce/schema.sql | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 dirs/ecommerce/migrations/20240714132123.sql diff --git a/dirs/ecommerce/migrations/20240714132123.sql b/dirs/ecommerce/migrations/20240714132123.sql new file mode 100644 index 0000000..3f25a25 --- /dev/null +++ b/dirs/ecommerce/migrations/20240714132123.sql @@ -0,0 +1,2 @@ +-- Modify "users" table +ALTER TABLE `users` ADD UNIQUE INDEX `email` (`email`); diff --git a/dirs/ecommerce/migrations/atlas.sum b/dirs/ecommerce/migrations/atlas.sum index 92d0dee..dc55b0b 100644 --- a/dirs/ecommerce/migrations/atlas.sum +++ b/dirs/ecommerce/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:8LeOgYv1dWVg/LAz7/Uv2sqRTcwUeEc5eTizTEVVgZE= +h1:66d9JjXdRay5AHv47FkWERP67UgtpudD5T8AE+rCIjQ= 20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo= 20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY= 20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA= @@ -21,3 +21,4 @@ h1:8LeOgYv1dWVg/LAz7/Uv2sqRTcwUeEc5eTizTEVVgZE= 20240702130812.sql h1:u9VyU0SQLuA1LotWpxsCyvEid5FMnrgatcn/P4S4F88= 20240704130806.sql h1:vUO9cakRAqDU9jNrQgE+qyWhWCkojRoWkjAtk9Z+wgY= 20240711130912.sql h1:ySpUVLDyz5QCRpeB3kaDVarV0hwqHEmwK9S5BEkG7Zo= +20240714132123.sql h1:lv0PHzxnTJyy62qY4O7uWPZ4nJHzuODG0PklM77dqtg= diff --git a/dirs/ecommerce/schema.sql b/dirs/ecommerce/schema.sql index 4d7bcad..23eb39b 100644 --- a/dirs/ecommerce/schema.sql +++ b/dirs/ecommerce/schema.sql @@ -10,7 +10,8 @@ CREATE TABLE `users` ( `date_of_birth` date NULL, `active` bool NOT NULL DEFAULT 1, `last_login` timestamp NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE INDEX `email` (`email`) ) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; -- Create "categories" table CREATE TABLE `categories` (