import migrations and don't require diesel_cli for admins (#555)
* import migrations via macro * panic on database not to the latest migration * add subcommand to plm * create migration that run tantivy index creation * remove diesel_cli from places it was * use our migration system for tests * create table __diesel_schema_migrations if needed
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
extern crate diesel;
|
||||
#[macro_use]
|
||||
extern crate diesel_migrations;
|
||||
|
||||
extern crate plume_common;
|
||||
extern crate plume_models;
|
||||
|
||||
use diesel::Connection;
|
||||
use plume_common::utils::random_hex;
|
||||
use plume_models::migrations::IMPORTED_MIGRATIONS;
|
||||
use plume_models::{Connection as Conn, CONFIG};
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
embed_migrations!("../migrations/sqlite");
|
||||
|
||||
#[cfg(feature = "postgres")]
|
||||
embed_migrations!("../migrations/postgres");
|
||||
use std::env::temp_dir;
|
||||
|
||||
fn db() -> Conn {
|
||||
let conn =
|
||||
Conn::establish(CONFIG.database_url.as_str()).expect("Couldn't connect to the database");
|
||||
embedded_migrations::run(&conn).expect("Couldn't run migrations");
|
||||
let dir = temp_dir().join(format!("plume-test-{}", random_hex()));
|
||||
IMPORTED_MIGRATIONS
|
||||
.run_pending_migrations(&conn, &dir)
|
||||
.expect("Couldn't run migrations");
|
||||
conn
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user