mirror of
https://github.com/ilyakooo0/reshape.git
synced 2024-11-29 12:03:35 +03:00
Remove truncation of migrations during abort
The migrations aren't updated so they shouldn't truncated during an abort either. Also fixes the indexing for contexts during aborts.
This commit is contained in:
parent
54d9dd1b44
commit
af2dbcb06e
@ -94,7 +94,7 @@ impl Reshape {
|
||||
self.state.applying(remaining_migrations.clone());
|
||||
self.state.save(&mut self.db)?;
|
||||
|
||||
println!(" Applying {} migrations\n", remaining_migrations.len());
|
||||
println!("Applying {} migrations\n", remaining_migrations.len());
|
||||
|
||||
helpers::set_up_helpers(&mut self.db, current_migration)
|
||||
.context("failed to set up helpers")?;
|
||||
@ -351,8 +351,6 @@ impl Reshape {
|
||||
// Abort all pending migrations
|
||||
abort_migrations(&mut transaction, remaining_migrations)?;
|
||||
|
||||
let keep_count = self.state.migrations.len() - remaining_migrations.len();
|
||||
self.state.migrations.truncate(keep_count);
|
||||
self.state.status = state::Status::Idle;
|
||||
self.state
|
||||
.save(&mut transaction)
|
||||
@ -368,9 +366,10 @@ impl Reshape {
|
||||
|
||||
fn abort_migrations(db: &mut dyn Conn, migrations: &[Migration]) -> anyhow::Result<()> {
|
||||
// Abort all migrations in reverse order
|
||||
for (migration_index, migration) in migrations.iter().rev().enumerate() {
|
||||
for (migration_index, migration) in migrations.iter().enumerate().rev() {
|
||||
print!("Aborting '{}' ", migration.name);
|
||||
for (action_index, action) in migration.actions.iter().rev().enumerate() {
|
||||
|
||||
for (action_index, action) in migration.actions.iter().enumerate().rev() {
|
||||
let ctx = MigrationContext::new(migration_index, action_index);
|
||||
action
|
||||
.abort(&ctx, db)
|
||||
|
Loading…
Reference in New Issue
Block a user