-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1939 from AdrienPoupa/migration-shouldrun
Add new shouldExecute method to prevent a migration or seeder from being executed
- Loading branch information
Showing
11 changed files
with
249 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/Phinx/Migration/_files/seeds/UserSeederNotExecuted.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Phinx\Seed\AbstractSeed; | ||
|
||
class UserSeederNotExecuted extends AbstractSeed | ||
{ | ||
public function run() | ||
{ | ||
$data = [ | ||
[ | ||
'name' => 'foo', | ||
'created' => date('Y-m-d H:i:s'), | ||
], | ||
[ | ||
'name' => 'bar', | ||
'created' => date('Y-m-d H:i:s'), | ||
], | ||
]; | ||
|
||
$users = $this->table('users'); | ||
$users->insert($data) | ||
->save(); | ||
} | ||
|
||
public function shouldExecute() | ||
{ | ||
return false; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/Phinx/Migration/_files/should_execute/20201207205056_should_not_execute_migration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class ShouldNotExecuteMigration extends AbstractMigration | ||
{ | ||
public function change() | ||
{ | ||
// info table | ||
$this->table('info')->create(); | ||
} | ||
|
||
public function shouldExecute() | ||
{ | ||
return false; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/Phinx/Migration/_files/should_execute/20201207205057_should_execute_migration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class ShouldExecuteMigration extends AbstractMigration | ||
{ | ||
public function change() | ||
{ | ||
// info table | ||
$this->table('info')->create(); | ||
} | ||
|
||
public function shouldExecute() | ||
{ | ||
return true; | ||
} | ||
} |