zibings / stoic-php-web

Apache License 2.0
0 stars 0 forks source link

Change Query Logic for Drop Migrations #12

Closed AndyM84 closed 4 months ago

AndyM84 commented 9 months ago

Currently if a drop run fails, all subsequent drop runs will also fail to remove any tables on account of the migrator continuing to check for the file:

// stoic-migrate:230
$db->queryStored(($isDropping) ? MStrings::DropMigTable : MStrings::InstallMigTable);

if (!$isDropping) {
    $db->prepareStored(MStrings::InsertMigration, [':fileName' => MStrings::MigFile])->execute();
}

In reality, neither of those actions should be performed if the migration is a 'drop', and it shouldn't perform the migration table DROP command here at all, since it is added as a separate migration step at the end of the queue.

AndyM84 commented 9 months ago

Proposed new code:

if (!$isDropping) {
    $db->queryStored(MStrings::InstallMigTable);
    $db->prepareStored(MStrings::InsertMigration, [':fileName' => MStrings::MigFile])->execute();
} else {
    $db->queryStored(MStrings::DropMigTable);
}