Add creation timestamps
This commit is contained in:
parent
0fd63eb886
commit
e93bb3a21f
|
@ -183,6 +183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"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)",
|
"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)",
|
"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"
|
serde_json = "1.0"
|
||||||
|
|
||||||
[dependencies.diesel]
|
[dependencies.diesel]
|
||||||
features = ["postgres", "r2d2"]
|
features = ["postgres", "r2d2", "chrono"]
|
||||||
version = "*"
|
version = "*"
|
||||||
|
|
||||||
[dependencies.rocket_contrib]
|
[dependencies.rocket_contrib]
|
||||||
|
|
|
@ -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;
|
|
@ -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 diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||||
|
|
||||||
use activity_pub::activity::Activity;
|
use activity_pub::activity::Activity;
|
||||||
|
@ -16,7 +17,8 @@ pub struct Blog {
|
||||||
pub summary: String,
|
pub summary: String,
|
||||||
pub outbox_url: String,
|
pub outbox_url: String,
|
||||||
pub inbox_url: String,
|
pub inbox_url: String,
|
||||||
pub instance_id: i32
|
pub instance_id: i32,
|
||||||
|
pub creation_date: NaiveDateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
|
|
||||||
|
@ -11,7 +12,8 @@ pub struct Instance {
|
||||||
pub public_domain: String,
|
pub public_domain: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub local: bool,
|
pub local: bool,
|
||||||
pub blocked: bool
|
pub blocked: bool,
|
||||||
|
pub creation_date: NaiveDateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, BelongingToDsl};
|
use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, BelongingToDsl};
|
||||||
use diesel::dsl::any;
|
use diesel::dsl::any;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
@ -17,7 +18,8 @@ pub struct Post {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub content: String,
|
pub content: String,
|
||||||
pub published: bool,
|
pub published: bool,
|
||||||
pub license: String
|
pub license: String,
|
||||||
|
pub creation_date: NaiveDateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use bcrypt;
|
use bcrypt;
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, BelongingToDsl, PgConnection};
|
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, BelongingToDsl, PgConnection};
|
||||||
use diesel::dsl::any;
|
use diesel::dsl::any;
|
||||||
use rocket::request::{self, FromRequest, Request};
|
use rocket::request::{self, FromRequest, Request};
|
||||||
|
@ -27,7 +28,8 @@ pub struct User {
|
||||||
pub summary: String,
|
pub summary: String,
|
||||||
pub email: Option<String>,
|
pub email: Option<String>,
|
||||||
pub hashed_password: Option<String>,
|
pub hashed_password: Option<String>,
|
||||||
pub instance_id: i32
|
pub instance_id: i32,
|
||||||
|
pub creation_date: NaiveDateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
|
|
|
@ -16,6 +16,7 @@ table! {
|
||||||
outbox_url -> Varchar,
|
outbox_url -> Varchar,
|
||||||
inbox_url -> Varchar,
|
inbox_url -> Varchar,
|
||||||
instance_id -> Int4,
|
instance_id -> Int4,
|
||||||
|
creation_date -> Timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ table! {
|
||||||
name -> Varchar,
|
name -> Varchar,
|
||||||
local -> Bool,
|
local -> Bool,
|
||||||
blocked -> Bool,
|
blocked -> Bool,
|
||||||
|
creation_date -> Timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +49,7 @@ table! {
|
||||||
content -> Text,
|
content -> Text,
|
||||||
published -> Bool,
|
published -> Bool,
|
||||||
license -> Varchar,
|
license -> Varchar,
|
||||||
|
creation_date -> Timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +65,7 @@ table! {
|
||||||
email -> Nullable<Text>,
|
email -> Nullable<Text>,
|
||||||
hashed_password -> Nullable<Text>,
|
hashed_password -> Nullable<Text>,
|
||||||
instance_id -> Int4,
|
instance_id -> Int4,
|
||||||
|
creation_date -> Timestamp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue