From e92dfcccf9f17294dff41b8f3631bd57a88da184 Mon Sep 17 00:00:00 2001 From: GitHub Gen Changes <> Date: Sun, 10 Nov 2024 13:09:04 +0000 Subject: [PATCH] Added a 'created_at' column to the 'posts' table with default current timestamp to track when each post is created. --- dirs/ecommerce/migrations/20241110130904.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/20241110130904.sql diff --git a/dirs/ecommerce/migrations/20241110130904.sql b/dirs/ecommerce/migrations/20241110130904.sql new file mode 100644 index 0000000..19d1b2d --- /dev/null +++ b/dirs/ecommerce/migrations/20241110130904.sql @@ -0,0 +1,2 @@ +-- Modify "posts" table +ALTER TABLE `posts` ADD COLUMN `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT "Timestamp of when the post was created"; diff --git a/dirs/ecommerce/migrations/atlas.sum b/dirs/ecommerce/migrations/atlas.sum index de207fe..11320e0 100644 --- a/dirs/ecommerce/migrations/atlas.sum +++ b/dirs/ecommerce/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:VSgYYYLSJhU5/Y7ZagWoPjc/Tlm9/OPPc36Eq5d5UDI= +h1:mQ4os5dvdZVxq9ucRsiEYty95umfc04MMDQfT68e+VI= 20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo= 20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY= 20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA= @@ -58,3 +58,4 @@ h1:VSgYYYLSJhU5/Y7ZagWoPjc/Tlm9/OPPc36Eq5d5UDI= 20241031131151.sql h1:XisKAigww2gisByYOPuIgNQcBOVX/AVKLNt0KGPrlU0= 20241105131055.sql h1:Pa43oRSXYgYlTyRPmz+ifOUdjC37MBxXty/y6GLCaqk= 20241107131023.sql h1:ZCiG0I6S1KZRirv89U4894V9ZBuG6ChLYDuPyWC098c= +20241110130904.sql h1:qRQ+S6KPxiFyp8VxRMkZIFVop3rO1qrS3EJpKz2gjhw= diff --git a/dirs/ecommerce/schema.sql b/dirs/ecommerce/schema.sql index a0f25b3..b28a8c0 100644 --- a/dirs/ecommerce/schema.sql +++ b/dirs/ecommerce/schema.sql @@ -133,6 +133,7 @@ CREATE TABLE `posts` ( `title` varchar(255) NOT NULL, `body` text NOT NULL, `last_updated_by` int NULL, + `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp of when the post was created', 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, @@ -151,4 +152,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;