-
-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom migration runner, forbid some diesel migration
commands, fix old migrations
#4673
Conversation
diesel migration
no longer allowed)
diesel migration
no longer allowed)diesel migration
commands no longer allowed)
diesel migration
commands no longer allowed)diesel migration
commands, fix old migrations
Once this passes, I'll test with a local production DB to make sure everything is okay. Then we should get this merged because it is an older PR. |
Trying to test this with a prod db, but running this with
|
…nstead of current working directory
try again with the new commit |
Error is now Maybe we need to add a different env var for that. Or just embed them even if its debug. |
I will move the use of FileBasedMigrations to a separate PR |
Testing this out now, seems to be going okay, but the |
K it did work correctly, so this can probably be merged. (well, loading pages is broken but that's not due to this PR). Here's the migration times btw, for a lemmy.ml prod DB on my dev machine. The smoosh migration took ~3 hours, which is unfortunate but I greatly doubt there's a way to speed that up.
cc @Nutomic |
#[arg(long, default_value_t = 1)] | ||
number: u64, | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These params need documentation, especially number is unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1,40 @@ | |||
#![expect(clippy::expect_used)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also mark this file as cfg[test]
so it cannot accidentally be used from production code and result in crashes from expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved the attribute here
crates/db_schema/src/schema_setup.rs
Outdated
/// Reduces clutter | ||
fn o() -> Options { | ||
Options::default() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define a variable instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Damn thats a very long downtime. It would definitely be good if we could optimize that in some way. |
crates/db_schema/src/schema_setup.rs
Outdated
|
||
let duration = start_time.elapsed().as_millis(); | ||
let name = migration.name(); | ||
println!("{duration}ms revert {name}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can convert the duration to chrono::TimeDelta
which has a Display
impl and should work better to display longer durations. Same for run_migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
I looked over |
I'm now working on a PR to try to optimize some of the migrations, including smoosh-tables-together |
Reverting and testing migrations will be done with
lemmy_server migration
commands, anddiesel migration
commands will do nothing and fail when trying to run or revert migrations.Benefits:
All migrations, not just the newest one, will be tested with schema diff(moved to Improve migration diff check and fix old migrations #5204)#4333 (comment)
The new tests (even just reverting all migrations) revealed some mistakes in old migrations, so I fixed those, and I also discovered that'now'::timestamp
in old views used the timestamp of the view's creation instead of the current timestamp.