From debc818a4e3b3baff2f7295f1e693653c5ebd02e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 23 Oct 2017 14:22:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88config=20option=20=E5=92=8Cpa?= =?UTF-8?q?th=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=20=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=9B=BA=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Command.php | 2 ++ src/command/Migrate.php | 21 +-------------------- src/command/Seed.php | 2 +- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/Command.php b/src/Command.php index d22d6ca..f720dfa 100644 --- a/src/Command.php +++ b/src/Command.php @@ -17,6 +17,8 @@ use think\facade\Config; abstract class Command extends \think\console\Command { + protected $config = 'database'; + public function getAdapter() { if (isset($this->adapter)) { diff --git a/src/command/Migrate.php b/src/command/Migrate.php index 18e0b77..0659b8e 100644 --- a/src/command/Migrate.php +++ b/src/command/Migrate.php @@ -17,7 +17,6 @@ use Phinx\Migration\AbstractMigration; use Phinx\Migration\MigrationInterface; use Phinx\Util\Util; use think\console\Input; -use think\console\input\Option as InputOption; use think\console\Output; use think\facade\Env; use think\migration\Command; @@ -30,27 +29,9 @@ abstract class Migrate extends Command */ protected $migrations; - public function __construct($name = null) - { - - parent::__construct($name); - - $this->addOption('--config', null, InputOption::VALUE_REQUIRED, 'The database config name', 'database'); - } - - /** - * 初始化 - * @param Input $input An InputInterface instance - * @param Output $output An OutputInterface instance - */ - protected function initialize(Input $input, Output $output) - { - $this->config = $input->getOption('config'); - } - protected function getPath() { - return $this->getConfig('path', Env::get('root_path') . 'database') . DIRECTORY_SEPARATOR . 'migrations' . ('database' !== $this->config ? DIRECTORY_SEPARATOR . $this->config : ''); + return Env::get('root_path') . 'database' . DIRECTORY_SEPARATOR . 'migrations'; } protected function executeMigration(MigrationInterface $migration, $direction = MigrationInterface::UP) diff --git a/src/command/Seed.php b/src/command/Seed.php index e3666f5..8639dda 100644 --- a/src/command/Seed.php +++ b/src/command/Seed.php @@ -27,7 +27,7 @@ abstract class Seed extends Command protected function getPath() { - return $this->getConfig('path', Env::get('root_path') . 'database') . DIRECTORY_SEPARATOR . 'seeds'; + return Env::get('root_path') . 'database' . DIRECTORY_SEPARATOR . 'seeds'; } public function getSeeds()