Skip to content

Commit ee2a7ec

Browse files
committed
add proper logging of migrations
1 parent 79c7527 commit ee2a7ec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/webserver/database/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ pub async fn apply_migrations(db: &Database) -> anyhow::Result<()> {
5353
let migrator = Migrator::new(migrations_dir)
5454
.await
5555
.with_context(|| migration_err("preparing the database migration"))?;
56+
if migrator.migrations.is_empty() {
57+
log::info!("No migration found. \
58+
You can specify database operations to apply when the server first starts by creating files \
59+
in {MIGRATIONS_DIR}/<VERSION>_<DESCRIPTION>.sql \
60+
where <VERSION> is a number and <DESCRIPTION> is a short string.");
61+
return Ok(());
62+
}
63+
log::info!("Found {} migrations:", migrator.migrations.len());
64+
for m in migrator.iter() {
65+
log::info!(
66+
"\t[{:04}] {:?} {}",
67+
m.version,
68+
m.migration_type,
69+
m.description
70+
);
71+
}
5672
migrator
5773
.run(&db.connection)
5874
.await

0 commit comments

Comments
 (0)