Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDon't print migration output when running the initial setup migration #1023
Comments
sgrif
added
the
good first issue
label
Jul 13, 2017
This comment has been minimized.
|
Would love to work on this @sgrif if that's cool. |
This comment has been minimized.
|
Sure |
This comment has been minimized.
|
Awesome. i'll try to submit a PR tomorrow afternoon. Ty |
This comment has been minimized.
|
So there's a few ways to accomplish this, but the most apparent but "not so elegant" way to do it is wrapping an Something like: fn run_migration<Conn>(conn: &Conn, migration: &Migration, output: &mut Write)
-> Result<(), RunMigrationsError> where
Conn: MigrationConnection,
{
conn.transaction(|| {
if migration.version() !== "00000000000000" {
try!(writeln!(output, "Running migration {}", migration.version()));
}
try!(migration.run(conn));
try!(conn.insert_new_migration(migration.version()));
Ok(())
})
}It definitely seems like it could be cleaner but I didn't want to over think it. The thought hole I went down was: at this point the I suppose I could also check if the first version equals the last version which might look nicer imo but it's not as clear if you're reading it -> If I'm understanding the architecture correctly that is. |
This comment has been minimized.
|
That change is pretty much exactly what I want. There's really no need to overthink it (we should probably have a test that |
This comment has been minimized.
|
Sounds good! |
sgrif commentedJul 13, 2017
I mostly want the initial setup migration to be invisible. We shouldn't have this in the output:
This just requires special casing that version in the function which prints that line.