-
-
Notifications
You must be signed in to change notification settings - Fork 520
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
cargo run -- up can not update the table field #989
Comments
That's the expected behaviour according to the source code: async fn up(db: &DbConn, mut steps: Option<u32>) -> Result<(), DbErr> {
Self::install(db).await?;
let manager = SchemaManager::new(db);
if let Some(steps) = steps {
info!("Applying {} pending migrations", steps);
} else {
info!("Applying all pending migrations");
}
let migrations = Self::get_pending_migrations(db).await?.into_iter();
if migrations.len() == 0 {
info!("No pending migrations");
}
// skipped
} The cli first checks the Therefore, in your attempt there is no pending migration. To add a new migration, you should generate a new migration as documented here. Alternatively, if you just want to edit the already migrated file, you can first roll it back before running it again. Hope this helps. |
Hey @diaojunxian, welcome! Sorry for the delay. I'm pretty sure the migration You have two options:
|
Thanks!! @ctfdavis |
This might be related |
Hey @diaojunxian, as a temporary workaround: execute |
Hi @billy1624 , Thanks a lot for your answer. I have figured out what the current principle. I describe my desired scenario. when had created a data table, the service also inserted some data normally. At this time, when want to update the data table fields, for example, append two fields. then, it is not feasible for me to add it to the original m20220120_000001_create_post_table. And need to create a new m20220120_000002_create_post_table, and then execute |
It's not desire to alter the old (applied) migration. You should always create a new migration if you want to alter the schema. However, if you insist to change the old (applied) migration. You can rollback the migration then re-apply it by first executing |
Description
In poem_example,update the table field in entity posts, add two fields, and then add two fields in
migration/ m20220120_000001_create_post_table
then execute
migration/main.rs
,and the execution result is
and find that the fields in the database posts table are not updated.
why
Applying 1 pending migrations
,but the result isNo pending migrations
The text was updated successfully, but these errors were encountered: