Skip to content

Commit

Permalink
Add timestamp column to table to track the last update time of a user…
Browse files Browse the repository at this point in the history
… record.
  • Loading branch information
GitHub Gen Changes committed Jun 20, 2024
1 parent 557dbb5 commit 7d91b9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions dirs/ecommerce/migrations/20240620130747.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "users" table
ALTER TABLE `users` ADD COLUMN `updated_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP;
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:er9U3Zz9HEKlMqmfdYRW3wX7ExkH173eYdgpUuiRaes=
h1:WYJgMe6FV2mNO59b1qqxHBhwzPexSnZnEkduM1CflDM=
20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo=
20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY=
20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA=
Expand All @@ -14,3 +14,4 @@ h1:er9U3Zz9HEKlMqmfdYRW3wX7ExkH173eYdgpUuiRaes=
20240324131640_order_comment.sql h1:TCduwlpoGZn9Zi6v5t3YzaAkeVgQX5fJ96ZbBJbR0MA=
20240617144354.sql h1:mGm4AgdRP4D1QN/FUNB71vqwLi/faoukUxc6OQVppVY=
20240619073333.sql h1:QJKiWNUwcmy8hbt6YiiVWew5AgibFgtBHBKe73NXW6s=
20240620130747.sql h1:0v/yTN8W9PHjGLN6ZE+T8XywRRUJXwRUt23XWewGyhg=
3 changes: 2 additions & 1 deletion dirs/ecommerce/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CREATE TABLE `users` (
`email` varchar(255) NOT NULL,
`is_admin` bool NULL DEFAULT 0,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP,
`date_of_birth` date NULL,
PRIMARY KEY (`id`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
Expand Down Expand Up @@ -107,4 +108,4 @@ CREATE TABLE `posts` (
PRIMARY KEY (`id`),
INDEX `user_id` (`user_id`),
CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

0 comments on commit 7d91b9b

Please sign in to comment.