From 73b24a3a1c303656e93cd9e9203d6da61ce63db5 Mon Sep 17 00:00:00 2001 From: kirbylife Date: Tue, 20 Dec 2022 22:33:10 -0600 Subject: [PATCH] Add views field in the database --- src/models.rs | 2 ++ src/schema.rs | 3 ++- templates/admin/add_post.html.tera | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/models.rs b/src/models.rs index 268a264..429d53c 100644 --- a/src/models.rs +++ b/src/models.rs @@ -9,6 +9,7 @@ pub struct Post { pub title: String, pub content: String, pub published: bool, + pub views: i32, pub created_at: NaiveDateTime, pub updated_at: NaiveDateTime, } @@ -19,4 +20,5 @@ pub struct NewPost { pub title: String, pub content: String, pub published: bool, + pub views: i32, } diff --git a/src/schema.rs b/src/schema.rs index b93068c..84a187d 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1,9 +1,10 @@ table! { posts (id) { - id -> Int4, + id -> Integer, title -> Varchar, content -> Text, published -> Bool, + views -> Integer, created_at -> Timestamp, updated_at -> Timestamp, } diff --git a/templates/admin/add_post.html.tera b/templates/admin/add_post.html.tera index 439705c..3b20401 100644 --- a/templates/admin/add_post.html.tera +++ b/templates/admin/add_post.html.tera @@ -31,6 +31,7 @@ +