gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit 46bb4c21a68ddc9cde58994ab55a88fecfdf7aa2
parent d51b641adc78ba12c391779d27a1c6b89bf698b5
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun, 24 May 2020 09:54:21 -0500

Embed diesel migrations

Don't require users to run diesel_cli, embed migrations and run on
startup instead.

Diffstat:
MCargo.lock | 34+++++++++++++++++++++++++++++++++-
MCargo.toml | 1+
Msrc/lib.rs | 2+-
Msrc/main.rs | 8++++++++
4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -405,6 +405,16 @@ dependencies = [ ] [[package]] +name = "diesel_migrations" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3cde8413353dc7f5d72fa8ce0b99a560a359d2c5ef1e5817ca731cd9008f4c" +dependencies = [ + "migrations_internals", + "migrations_macros", +] + +[[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -639,7 +649,7 @@ dependencies = [ [[package]] name = "gourami_social" -version = "0.1.0" +version = "0.1.1" dependencies = [ "activitystreams", "ammonia", @@ -649,6 +659,7 @@ dependencies = [ "chrono", "clap", "diesel", + "diesel_migrations", "dotenv", "env_logger", "http-signature-normalization", @@ -1008,6 +1019,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" [[package]] +name = "migrations_internals" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b4fc84e4af020b837029e017966f86a1c2d5e83e64b589963d5047525995860" +dependencies = [ + "diesel", +] + +[[package]] +name = "migrations_macros" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" +dependencies = [ + "migrations_internals", + "proc-macro2 1.0.12", + "quote 1.0.5", + "syn 1.0.21", +] + +[[package]] name = "mime" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -13,6 +13,7 @@ bcrypt = "0.7.0" chrono = {version="0.4.11", features=["serde"]} clap = "2.33.0" diesel = { version = "1.4.4", features = ["sqlite", "chrono", "r2d2"] } +diesel_migrations = "1.4.0" dotenv = "0.15.0" env_logger = "0.7.1" http-signature-normalization = "0.5.1" diff --git a/src/lib.rs b/src/lib.rs @@ -21,7 +21,7 @@ use warp::redirect::redirect; use warp::{Filter, Rejection, Reply}; use askama::Template; -use db::conn::POOL; +pub use db::conn::POOL; use db::note; use db::note::{Note, NoteInput}; use db::notification::{NewNotification, NewNotificationViewer, Notification, NotificationViewer}; diff --git a/src/main.rs b/src/main.rs @@ -1,12 +1,20 @@ use clap::{App, Arg, SubCommand}; use dotenv; use gourami_social::ap; +use gourami_social::POOL; use gourami_social::routes::run_server; +#[macro_use] +extern crate diesel_migrations; + +embed_migrations!("./migrations"); + #[tokio::main] async fn main() { dotenv::dotenv().ok(); env_logger::init(); + let conn = &POOL.get().unwrap(); + embedded_migrations::run(conn).unwrap(); let matches = App::new("Gourami") .version("0.1.1") .author("Alex Wennerberg <alex@alexwennerberg.com>")