Skip to content

Commit

Permalink
マイグレーションの判定コマンドを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Nov 14, 2022
1 parent 28008f0 commit d682388
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugins/baser-core/src/BcPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public function rollbackDb($options = []): bool
*/
public function routes($routes): void
{
if (!BcUtil::isInstalled()) {
if (!BcUtil::isInstalled() || BcUtil::isMigrations()) {
parent::routes($routes);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/baser-core/src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public function routes($routes): void
{

// migrations コマンドの場合は実行しない
if(isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] === 'migrations') {
if(BcUtil::isMigrations()) {
parent::routes($routes);
return;
}
Expand Down
15 changes: 15 additions & 0 deletions plugins/baser-core/src/Utility/BcUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -1587,4 +1587,19 @@ public static function fullUrl($url)
return self::topLevelUrl(false) . $url;
}

/**
* 現在の処理がCakePHPのマイグレーションコマンドかどうか
*
* @return bool
* @checked
* @noTodo
*/
public static function isMigrations()
{
if(self::isConsole() && isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] === 'migrations') {
return true;
}
return false;
}

}

0 comments on commit d682388

Please sign in to comment.