Skip to content

Commit

Permalink
Renamed column 'email' to 'email_address' in the 'users' table, which…
Browse files Browse the repository at this point in the history
… is a backward-incompatible change as it may break existing queries using the old column name. (#137)

Co-authored-by: GitHub Gen Changes <>
  • Loading branch information
ariga-bot authored Jan 6, 2025
1 parent 9873852 commit 38754fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions dirs/ecommerce/migrations/20250105130916.sql
Original file line number Diff line number Diff line change
@@ -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`);
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:Rn+1tTkF/iDeC1Y5mm6Zi1/SYwVmghRJhikPGEsH/a0=
h1:IYFRbQe36sOOtZW5CJso8BxeJn95HOiqPtGHkPUHLUY=
20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo=
20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY=
20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA=
Expand Down Expand Up @@ -67,3 +67,4 @@ h1:Rn+1tTkF/iDeC1Y5mm6Zi1/SYwVmghRJhikPGEsH/a0=
20241222081015.sql h1:RU7o+jkmMTI4Okz56YG4sZYRL2P+YMvcXfLlIYR8Rk8=
20241224131007.sql h1:OHMWMynd3YnU6t9QKs1R8ei2BbbNlZ66Tx73jgmeJUM=
20250102131036.sql h1:NEfnhChNfi18FzcgQ4Jsc1ygWpGH19GNvu98+3VVTgQ=
20250105130916.sql h1:J+F2PZSoMGyArqfu99kOHzOIHOFw/v4ps8CmFlqc0Fw=
8 changes: 4 additions & 4 deletions dirs/ecommerce/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -20,11 +20,11 @@ CREATE TABLE `users` (
`deleted_at` timestamp NULL COMMENT 'Timestamp for soft deletion of the user record',
`last_order_date` date NULL COMMENT 'Date of the user\'s last order',
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';

Expand Down

0 comments on commit 38754fa

Please sign in to comment.