mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
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:
9 files changed
+170
-159
No files matched your search
+19
-15
@@ -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
|
||||
);
|
||||
"##;
|
||||
Reference in new issue
Block a user