From 8ed2e0f67d43d1709b6ff40c39b3b7d465eb15d2 Mon Sep 17 00:00:00 2001 From: GitHub Gen Changes <> Date: Sun, 22 Dec 2024 13:09:15 +0000 Subject: [PATCH] Renamed column in table to , causing potential backward-incompatibility with applications referencing the old column name. --- dirs/ecommerce/migrations/20241222130915.sql | 2 ++ dirs/ecommerce/migrations/atlas.sum | 3 ++- dirs/ecommerce/schema.sql | 10 +++++----- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 dirs/ecommerce/migrations/20241222130915.sql diff --git a/dirs/ecommerce/migrations/20241222130915.sql b/dirs/ecommerce/migrations/20241222130915.sql new file mode 100644 index 0000000..64f9f15 --- /dev/null +++ b/dirs/ecommerce/migrations/20241222130915.sql @@ -0,0 +1,2 @@ +-- Modify "users" table +ALTER TABLE `users` DROP CHECK `users_chk_1`, ADD CONSTRAINT `users_chk_1` CHECK (regexp_like(`email_address`,_utf8mb4'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$')), DROP COLUMN `email`, ADD COLUMN `email_address` varchar(255) NOT NULL, DROP INDEX `user_name_email`, ADD UNIQUE INDEX `email_address` (`email_address`), ADD UNIQUE INDEX `user_name_email_address` (`user_name`, `email_address`); diff --git a/dirs/ecommerce/migrations/atlas.sum b/dirs/ecommerce/migrations/atlas.sum index 5f5e323..1cad2c1 100644 --- a/dirs/ecommerce/migrations/atlas.sum +++ b/dirs/ecommerce/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:26Zy884xkjsjaKDTmH4Ds4IH07GTWoldeCOClJZPk3I= +h1:+Ow2DbyvVMO/HkKVAb5SlO7eZUpProY2iF2p/BkYdQc= 20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo= 20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY= 20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA= @@ -65,3 +65,4 @@ h1:26Zy884xkjsjaKDTmH4Ds4IH07GTWoldeCOClJZPk3I= 20241128114310.sql h1:BEWCkwlqS1vHduvpN0PlbUZq1nwe/6iLCkrKfECzprk= 20241217131440.sql h1:LBppckudt/r82v6i910RWNoBAHQ7E3KwrMHETxwXfF4= 20241222081015.sql h1:RU7o+jkmMTI4Okz56YG4sZYRL2P+YMvcXfLlIYR8Rk8= +20241222130915.sql h1:iRID6SxvHPxKHC8etWE3ywN8PewfL4FFTOGlSTLiDeQ= diff --git a/dirs/ecommerce/schema.sql b/dirs/ecommerce/schema.sql index d237f40..17f8997 100644 --- a/dirs/ecommerce/schema.sql +++ b/dirs/ecommerce/schema.sql @@ -2,7 +2,7 @@ CREATE TABLE `users` ( `id` int NOT NULL COMMENT 'Unique identifier for each user', `user_name` varchar(255) NOT NULL COMMENT 'The username of the user, must be unique', - `email` varchar(255) NOT NULL, + `email_address` varchar(255) NOT NULL, `phone_number` varchar(15) NOT NULL, `country_code` varchar(5) NOT NULL DEFAULT '+1' COMMENT 'Country code for the phone number, defaults to US', `is_admin` bool NULL DEFAULT 0 COMMENT 'Flag indicating if the user is an admin, defaults to false', @@ -19,11 +19,11 @@ CREATE TABLE `users` ( `phone_verified` bool NOT NULL DEFAULT 0 COMMENT 'Flag indicating if the user phone number is verified, defaults to false', `deleted_at` timestamp NULL COMMENT 'Timestamp for soft deletion of the user record', PRIMARY KEY (`id`), - UNIQUE INDEX `email` (`email`), + UNIQUE INDEX `email_address` (`email_address`), UNIQUE INDEX `user_name` (`user_name`), UNIQUE INDEX `phone_number` (`phone_number`), - UNIQUE INDEX `user_name_email` (`user_name`, `email`), - CHECK (`email` REGEXP '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'), + UNIQUE INDEX `user_name_email_address` (`user_name`, `email_address`), + CHECK (`email_address` REGEXP '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'), CHECK (`phone_number` REGEXP '^[0-9]{1,15}$') ) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT 'Table storing user information, including authentication and profile details'; @@ -158,4 +158,4 @@ CREATE TABLE `payment_methods` ( PRIMARY KEY (`id`), INDEX `user_id` (`user_id`), CONSTRAINT `payment_methods_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE -) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci; \ No newline at end of file +) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;