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:
+17
@@ -41,6 +41,7 @@ extern crate webfinger;
|
||||
use diesel::r2d2::ConnectionManager;
|
||||
use plume_models::{
|
||||
db_conn::{DbPool, PragmaForeignKey},
|
||||
migrations::IMPORTED_MIGRATIONS,
|
||||
search::{Searcher as UnmanagedSearcher, SearcherError},
|
||||
Connection, Error, CONFIG,
|
||||
};
|
||||
@@ -83,6 +84,22 @@ fn init_pool() -> Option<DbPool> {
|
||||
|
||||
fn main() {
|
||||
let dbpool = init_pool().expect("main: database pool initialization error");
|
||||
if IMPORTED_MIGRATIONS
|
||||
.is_pending(&dbpool.get().unwrap())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
panic!(
|
||||
r#"
|
||||
It appear your database migration does not run the migration required
|
||||
by this version of Plume. To fix this, you can run migrations via
|
||||
this command:
|
||||
|
||||
plm migration run
|
||||
|
||||
Then try to restart Plume.
|
||||
"#
|
||||
)
|
||||
}
|
||||
let workpool = ScheduledThreadPool::with_name("worker {}", num_cpus::get());
|
||||
// we want a fast exit here, so
|
||||
#[allow(clippy::match_wild_err_arm)]
|
||||
|
||||
Reference in New Issue
Block a user