Skip to content

Commit 21e11bd

Browse files
authored
Change column in the table to allow NULL values, reducing the strictness on user phone registration. (#236)
Co-authored-by: GitHub Gen Changes <>
1 parent 786aea6 commit 21e11bd

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Modify "users" table
2+
ALTER TABLE `users` DROP CHECK `users_chk_2`, ADD CONSTRAINT `users_chk_2` CHECK (regexp_like(`phone_number`,_utf8mb4'^[0-9]{1,15}$') or (`phone_number` is null)), MODIFY COLUMN `phone_number` varchar(15) NULL COMMENT "Phone number of the user, now allowed to be NULL";

dirs/ecommerce/migrations/atlas.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
h1:Z7B7yZYP2VvVo+P1SCtT12T7tL5lYRBafjuC+XI7qgU=
1+
h1:Bq3NIVFE1ptNc3wON4D0d1z8IoVJHz61OfDfRO6lPZQ=
22
20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo=
33
20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY=
44
20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA=
@@ -132,3 +132,4 @@ h1:Z7B7yZYP2VvVo+P1SCtT12T7tL5lYRBafjuC+XI7qgU=
132132
20251109131247.sql h1:tnLmsPNKQbmdT4G/39R78TAjmd3Yo+gO4UJ+EW3tDQI=
133133
20251111131804.sql h1:Gy4czEA8J3HS+fGnf7tTHsNxoqE5ccI1cDB2wWpard4=
134134
20251113131822.sql h1:Nj5q9s7cNRNlX5uBbXDC+hXRTFIHbI5hY2B/zZ/6PHE=
135+
20251116131259.sql h1:SXEM8wtSpFOda17yyUasKJNAtN2OLkBXCp1rT52jplk=

dirs/ecommerce/schema.sql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE TABLE `users` (
33
`id` int NOT NULL COMMENT 'Unique identifier for each user',
44
`user_name` varchar(255) COLLATE utf8mb4_0900_as_ci NOT NULL COMMENT 'The username of the user, must be unique',
55
`email_address` varchar(255) COLLATE utf8mb4_0900_as_ci NOT NULL COMMENT 'Email address of the user, now stored case-insensitively',
6-
`phone_number` varchar(15) NOT NULL,
6+
`phone_number` varchar(15) NULL COMMENT 'Phone number of the user, now allowed to be NULL',
77
`country_code` char(3) NOT NULL DEFAULT '+1' COMMENT 'Country code for the phone number, defaults to US',
88
`is_admin` bool NULL DEFAULT 0 COMMENT 'Flag indicating if the user is an admin, defaults to false',
99
`email_verified` bool NOT NULL DEFAULT 0 COMMENT 'Flag indicating if the user email address is verified, defaults to false',
@@ -32,7 +32,7 @@ CREATE TABLE `users` (
3232
UNIQUE INDEX `country_code_phone_number` (`country_code`, `phone_number`),
3333
INDEX `last_login` (`last_login`),
3434
CHECK (`email_address` REGEXP '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\0003\.[a-zA-Z]{2,}$'),
35-
CHECK (`phone_number` REGEXP '^[0-9]{1,15}$'),
35+
CHECK (`phone_number` REGEXP '^[0-9]{1,15}$' OR `phone_number` IS NULL),
3636
CHECK (`last_order_date` IS NULL OR `last_order_date` >= `created_at`),
3737
CHECK ((`phone_verified` = 0) OR (`phone_number` IS NOT NULL AND `phone_number` REGEXP '^[0-9]{1,15}$')),
3838
CHECK (`reward_points` >= 0 AND `reward_points` <= 10000)
@@ -211,5 +211,4 @@ BEGIN
211211
IF NEW.total_amount < order_total THEN
212212
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Order total amount must be greater than or equal to the total price of the order items';
213213
END IF;
214-
END;
215-
214+
END;

0 commit comments

Comments
 (0)