feat: add keywords support and migration file
This commit is contained in:
parent
5a18706160
commit
6df1e3743e
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE "public"."articles" DROP COLUMN keywords;
|
@ -0,0 +1,2 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE "public"."articles" ADD COLUMN keywords TEXT[] NOT NULL DEFAULT '{}'::text[];
|
@ -18,9 +18,6 @@ use dotenv::dotenv;
|
||||
|
||||
use crate::data::RubbleData;
|
||||
use crate::pg_pool::database_pool_establish;
|
||||
use actix_web::web::route;
|
||||
use rand::prelude::*;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use tera::compile_templates;
|
||||
use time::Duration;
|
||||
|
@ -18,6 +18,7 @@ pub struct Article {
|
||||
pub user_id: i32,
|
||||
pub publish_at: NaiveDateTime,
|
||||
pub url: Option<String>,
|
||||
pub keywords: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Insertable, AsChangeset, Serialize, Deserialize)]
|
||||
@ -33,14 +34,10 @@ pub struct NewArticle {
|
||||
}
|
||||
|
||||
impl Article {
|
||||
|
||||
pub fn link(&self) -> String {
|
||||
match self.url {
|
||||
Some(ref to) if to.len() != 0 => {
|
||||
format!("/{}", to)
|
||||
},
|
||||
_ => format!("/archives/{}", self.id)
|
||||
|
||||
Some(ref to) if to.len() != 0 => format!("/{}", to),
|
||||
_ => format!("/archives/{}", self.id),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ table! {
|
||||
user_id -> Int4,
|
||||
publish_at -> Timestamp,
|
||||
url -> Nullable<Text>,
|
||||
keywords -> Array<Text>,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user