From edbd1f62238f2dc524df08f10f3df7211284e2ff Mon Sep 17 00:00:00 2001 From: bush1D3v Date: Tue, 9 Jul 2024 17:21:55 -0300 Subject: [PATCH] update: Add a updated_at column to entity --- migrations/20240530181229_create_posts/up.sql | 1 + migrations/20240530181637_create_users/up.sql | 3 ++- migrations/20240530181926_create_comments/up.sql | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/migrations/20240530181229_create_posts/up.sql b/migrations/20240530181229_create_posts/up.sql index 8e6c6b8..120b350 100644 --- a/migrations/20240530181229_create_posts/up.sql +++ b/migrations/20240530181229_create_posts/up.sql @@ -4,5 +4,6 @@ CREATE TABLE posts ( subtitle VARCHAR(255) NOT NULL, body TEXT NOT NULL, created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL, likes INT DEFAULT 0 ); diff --git a/migrations/20240530181637_create_users/up.sql b/migrations/20240530181637_create_users/up.sql index b3e33a3..21546a2 100644 --- a/migrations/20240530181637_create_users/up.sql +++ b/migrations/20240530181637_create_users/up.sql @@ -3,5 +3,6 @@ CREATE TABLE users ( name VARCHAR(63) NOT NULL, email VARCHAR(127) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, - created_at TIMESTAMPTZ NOT NULL + created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL ); diff --git a/migrations/20240530181926_create_comments/up.sql b/migrations/20240530181926_create_comments/up.sql index 71ae84c..b9aa9b6 100644 --- a/migrations/20240530181926_create_comments/up.sql +++ b/migrations/20240530181926_create_comments/up.sql @@ -6,6 +6,7 @@ CREATE TABLE comments ( body TEXT NOT NULL, likes INT DEFAULT 0, created_at TIMESTAMPTZ NOT NULL, + updated_at TIMESTAMPTZ NOT NULL, FOREIGN KEY (post_id) REFERENCES posts (id), FOREIGN KEY (user_id) REFERENCES users (id), FOREIGN KEY (parent_comment_id) REFERENCES comments (id)