Skip to content

Commit

Permalink
Revert "Fix setting faked migrations as migrated"
Browse files Browse the repository at this point in the history
This reverts commit 2abf956.
  • Loading branch information
MasterOdin committed Dec 20, 2023
1 parent 2abf956 commit 5c855da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 35 deletions.
23 changes: 11 additions & 12 deletions src/Phinx/Migration/Manager/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public function executeMigration(MigrationInterface $migration, string $directio
$migration->{MigrationInterface::INIT}();
}

// begin the transaction if the adapter supports it
if ($this->getAdapter()->hasTransactions()) {
$this->getAdapter()->beginTransaction();
}

if (!$fake) {
// begin the transaction if the adapter supports it
if ($this->getAdapter()->hasTransactions()) {
$this->getAdapter()->beginTransaction();
}

// Run the migration
if (method_exists($migration, MigrationInterface::CHANGE)) {
if ($direction === MigrationInterface::DOWN) {
Expand All @@ -111,16 +111,15 @@ public function executeMigration(MigrationInterface $migration, string $directio
} else {
$migration->{$direction}();
}
}

// Record it in the database
$this->getAdapter()->migrated($migration, $direction, date('Y-m-d H:i:s', $startTime), date('Y-m-d H:i:s', time()));
// Record it in the database
$this->getAdapter()->migrated($migration, $direction, date('Y-m-d H:i:s', $startTime), date('Y-m-d H:i:s', time()));

// commit the transaction if the adapter supports it
if ($this->getAdapter()->hasTransactions()) {
$this->getAdapter()->commitTransaction();
// commit the transaction if the adapter supports it
if ($this->getAdapter()->hasTransactions()) {
$this->getAdapter()->commitTransaction();
}
}

$migration->postFlightCheck();
}

Expand Down
23 changes: 0 additions & 23 deletions tests/Phinx/Migration/Manager/EnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,29 +256,6 @@ public function testExecutingAChangeMigrationDown()
$this->environment->executeMigration($migration, MigrationInterface::DOWN);
}

public function testExecutingAFakeMigration()
{
// stub adapter
$adapterStub = $this->getMockBuilder('\Phinx\Db\Adapter\PdoAdapter')
->setConstructorArgs([[]])
->getMock();
$adapterStub->expects($this->once())
->method('migrated')
->willReturn($adapterStub);

$this->environment->setAdapter($adapterStub);

// migration
$migration = $this->getMockBuilder('\Phinx\Migration\AbstractMigration')
->setConstructorArgs(['mockenv', '20130301080000'])
->setMethods(['change'])
->getMock();
$migration->expects($this->never())
->method('change');

$this->environment->executeMigration($migration, MigrationInterface::UP, true);
}

public function testGettingInputObject()
{
$mock = $this->getMockBuilder('\Symfony\Component\Console\Input\InputInterface')
Expand Down

0 comments on commit 5c855da

Please sign in to comment.