mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-31 14:21:42 +00:00
fmt
This commit is contained in:
parent
e8e354c9b2
commit
402ab1414f
1 changed files with 14 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::{schema::previously_run_sql};
|
use crate::schema::previously_run_sql;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use diesel::{
|
use diesel::{
|
||||||
connection::SimpleConnection,
|
connection::SimpleConnection,
|
||||||
|
@ -6,9 +6,10 @@ use diesel::{
|
||||||
update,
|
update,
|
||||||
Connection,
|
Connection,
|
||||||
ExpressionMethods,
|
ExpressionMethods,
|
||||||
|
NullableExpressionMethods,
|
||||||
PgConnection,
|
PgConnection,
|
||||||
QueryDsl,
|
QueryDsl,
|
||||||
RunQueryDsl,NullableExpressionMethods
|
RunQueryDsl,
|
||||||
};
|
};
|
||||||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness};
|
use diesel_migrations::{EmbeddedMigrations, MigrationHarness};
|
||||||
use lemmy_utils::error::LemmyError;
|
use lemmy_utils::error::LemmyError;
|
||||||
|
@ -116,15 +117,13 @@ pub fn run(db_url: &str) -> Result<(), LemmyError> {
|
||||||
let name = migration.name();
|
let name = migration.name();
|
||||||
// TODO measure time on database
|
// TODO measure time on database
|
||||||
let start_time = Instant::now();
|
let start_time = Instant::now();
|
||||||
conn.run_migration(migration)
|
conn.run_migration(migration).map_err(|e| anyhow::anyhow!("Couldn't run migration {name}: {e}"))?;
|
||||||
.map_err(|e| anyhow::anyhow!("Couldn't run migration {name}: {e}"))?;
|
|
||||||
let duration = start_time.elapsed().as_millis();
|
let duration = start_time.elapsed().as_millis();
|
||||||
info!("{duration}ms {name}");
|
info!("{duration}ms {name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run replaceable_schema
|
// Run replaceable_schema
|
||||||
conn.batch_execute(&new_sql)
|
conn.batch_execute(&new_sql).context("Couldn't run SQL files in crates/db_schema/replaceable_schema")?;
|
||||||
.context("Couldn't run SQL files in crates/db_schema/replaceable_schema")?;
|
|
||||||
|
|
||||||
let num_rows_updated = update(previously_run_sql::table)
|
let num_rows_updated = update(previously_run_sql::table)
|
||||||
.set(previously_run_sql::content.eq(new_sql))
|
.set(previously_run_sql::content.eq(new_sql))
|
||||||
|
|
Loading…
Reference in a new issue