Add creation timestamps
This commit is contained in:
parent
0fd63eb886
commit
e93bb3a21f
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -183,6 +183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diesel_derives 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pq-sys 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -17,7 +17,7 @@ serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
||||
[dependencies.diesel]
|
||||
features = ["postgres", "r2d2"]
|
||||
features = ["postgres", "r2d2", "chrono"]
|
||||
version = "*"
|
||||
|
||||
[dependencies.rocket_contrib]
|
||||
|
5
migrations/2018-04-30-170445_timestamps/down.sql
Normal file
5
migrations/2018-04-30-170445_timestamps/down.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
ALTER TABLE posts DROP COLUMN creation_date;
|
||||
ALTER TABLE blogs DROP COLUMN creation_date;
|
||||
ALTER TABLE users DROP COLUMN creation_date;
|
||||
ALTER TABLE instances DROP COLUMN creation_date;
|
5
migrations/2018-04-30-170445_timestamps/up.sql
Normal file
5
migrations/2018-04-30-170445_timestamps/up.sql
Normal file
@ -0,0 +1,5 @@
|
||||
-- Your SQL goes here
|
||||
ALTER TABLE posts ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
ALTER TABLE blogs ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
ALTER TABLE users ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
||||
ALTER TABLE instances ADD COLUMN creation_date TIMESTAMP NOT NULL DEFAULT now();
|
@ -1,3 +1,4 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||
|
||||
use activity_pub::activity::Activity;
|
||||
@ -16,7 +17,8 @@ pub struct Blog {
|
||||
pub summary: String,
|
||||
pub outbox_url: String,
|
||||
pub inbox_url: String,
|
||||
pub instance_id: i32
|
||||
pub instance_id: i32,
|
||||
pub creation_date: NaiveDateTime
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -1,3 +1,4 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||
use std::iter::Iterator;
|
||||
|
||||
@ -11,7 +12,8 @@ pub struct Instance {
|
||||
pub public_domain: String,
|
||||
pub name: String,
|
||||
pub local: bool,
|
||||
pub blocked: bool
|
||||
pub blocked: bool,
|
||||
pub creation_date: NaiveDateTime
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -1,3 +1,4 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, BelongingToDsl};
|
||||
use diesel::dsl::any;
|
||||
use serde_json;
|
||||
@ -17,7 +18,8 @@ pub struct Post {
|
||||
pub title: String,
|
||||
pub content: String,
|
||||
pub published: bool,
|
||||
pub license: String
|
||||
pub license: String,
|
||||
pub creation_date: NaiveDateTime
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -1,4 +1,5 @@
|
||||
use bcrypt;
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, BelongingToDsl, PgConnection};
|
||||
use diesel::dsl::any;
|
||||
use rocket::request::{self, FromRequest, Request};
|
||||
@ -27,7 +28,8 @@ pub struct User {
|
||||
pub summary: String,
|
||||
pub email: Option<String>,
|
||||
pub hashed_password: Option<String>,
|
||||
pub instance_id: i32
|
||||
pub instance_id: i32,
|
||||
pub creation_date: NaiveDateTime
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -16,6 +16,7 @@ table! {
|
||||
outbox_url -> Varchar,
|
||||
inbox_url -> Varchar,
|
||||
instance_id -> Int4,
|
||||
creation_date -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +28,7 @@ table! {
|
||||
name -> Varchar,
|
||||
local -> Bool,
|
||||
blocked -> Bool,
|
||||
creation_date -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,6 +49,7 @@ table! {
|
||||
content -> Text,
|
||||
published -> Bool,
|
||||
license -> Varchar,
|
||||
creation_date -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +65,7 @@ table! {
|
||||
email -> Nullable<Text>,
|
||||
hashed_password -> Nullable<Text>,
|
||||
instance_id -> Int4,
|
||||
creation_date -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user