ref(backend) major refactor

- remove struct Post, use database schema and Map instead
- add sub_title
- replace NaiveDateTime with DateTime<Utc>
This commit is contained in:
lumither committed 2024-05-12 17:00:37 +08:00
1 parent 7d856f25a3
commit fd8b760b7f
9 files changed
+170 -159

No files matched your search

+19 -15
View File
@@ -1,18 +1,22 @@
use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use uuid::Uuid;
pub mod post;
#[derive(Debug, Serialize, Deserialize, FromRow)]
pub struct Post {
pub post_id: Uuid,
pub title: String,
pub summary: String,
pub content: String,
pub last_update: NaiveDateTime,
pub first_update: NaiveDateTime,
}
pub const POST_DB_MODEL: &str = r##"
CREATE TABLE IF NOT EXISTS Post
(
post_id UUID PRIMARY KEY,
title VARCHAR(255) NOT NULL,
summary TEXT,
sub_title TEXT,
content TEXT NOT NULL,
last_update TIMESTAMPTZ NOT NULL,
first_update TIMESTAMPTZ NOT NULL
);
"##;
pub const TAG_DB_MODEL: &str = r##"
CREATE TABLE IF NOT EXISTS Tag
(
post_id UUID NOT NULL,
tag VARCHAR(255) NOT NULL
);
"##;