From 63a2f7b7e3bec6d6849a597b67fdaf05e0bf623d Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 17 Oct 2024 11:17:50 +0200 Subject: [PATCH] Drop timestamp column from votes (ref #5016) --- crates/db_schema/src/impls/comment.rs | 1 - crates/db_schema/src/impls/post.rs | 1 - crates/db_schema/src/schema.rs | 2 -- crates/db_schema/src/source/comment.rs | 1 - crates/db_schema/src/source/post.rs | 1 - crates/db_views/src/post_view.rs | 1 - migrations/2024-10-17-091053_vote-no-timestamp/down.sql | 2 ++ migrations/2024-10-17-091053_vote-no-timestamp/up.sql | 2 ++ 8 files changed, 4 insertions(+), 7 deletions(-) create mode 100644 migrations/2024-10-17-091053_vote-no-timestamp/down.sql create mode 100644 migrations/2024-10-17-091053_vote-no-timestamp/up.sql diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index ec246c121..737486d92 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -300,7 +300,6 @@ mod tests { comment_id: inserted_comment.id, post_id: inserted_post.id, person_id: inserted_person.id, - published: inserted_comment_like.published, score: 1, }; diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index fb6245585..0a0b34db8 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -500,7 +500,6 @@ mod tests { let expected_post_like = PostLike { post_id: inserted_post.id, person_id: inserted_person.id, - published: inserted_post_like.published, score: 1, }; diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 5534c4f60..c89b1931e 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -125,7 +125,6 @@ diesel::table! { comment_id -> Int4, post_id -> Int4, score -> Int2, - published -> Timestamptz, } } @@ -816,7 +815,6 @@ diesel::table! { post_id -> Int4, person_id -> Int4, score -> Int2, - published -> Timestamptz, } } diff --git a/crates/db_schema/src/source/comment.rs b/crates/db_schema/src/source/comment.rs index e7d031c68..b7b4304fa 100644 --- a/crates/db_schema/src/source/comment.rs +++ b/crates/db_schema/src/source/comment.rs @@ -104,7 +104,6 @@ pub struct CommentLike { pub comment_id: CommentId, pub post_id: PostId, // TODO this is redundant pub score: i16, - pub published: DateTime, } #[derive(Clone)] diff --git a/crates/db_schema/src/source/post.rs b/crates/db_schema/src/source/post.rs index 3819bd773..e1de250c6 100644 --- a/crates/db_schema/src/source/post.rs +++ b/crates/db_schema/src/source/post.rs @@ -150,7 +150,6 @@ pub struct PostLike { pub post_id: PostId, pub person_id: PersonId, pub score: i16, - pub published: DateTime, } #[derive(Clone)] diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index e07133471..d05d668c2 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -1125,7 +1125,6 @@ mod tests { let expected_post_like = PostLike { post_id: data.inserted_post.id, person_id: data.local_user_view.person.id, - published: inserted_post_like.published, score: 1, }; assert_eq!(expected_post_like, inserted_post_like); diff --git a/migrations/2024-10-17-091053_vote-no-timestamp/down.sql b/migrations/2024-10-17-091053_vote-no-timestamp/down.sql new file mode 100644 index 000000000..295dafc42 --- /dev/null +++ b/migrations/2024-10-17-091053_vote-no-timestamp/down.sql @@ -0,0 +1,2 @@ +alter table post_like add column published timestamptz not null default now(); +alter table comment_like add column published timestamptz not null default now(); \ No newline at end of file diff --git a/migrations/2024-10-17-091053_vote-no-timestamp/up.sql b/migrations/2024-10-17-091053_vote-no-timestamp/up.sql new file mode 100644 index 000000000..0b4107735 --- /dev/null +++ b/migrations/2024-10-17-091053_vote-no-timestamp/up.sql @@ -0,0 +1,2 @@ +alter table post_like drop published; +alter table comment_like drop published; \ No newline at end of file