Skip to content

Commit

Permalink
支持新配置格式
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Jun 17, 2019
1 parent 46d0e8c commit e8b3396
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function getAdapter()
*/
protected function getDbConfig(): array
{
$config = $this->app->config->get('database');
$default = $this->app->config->get('database.default');

$config = $this->app->config->get("database.connections.{$default}");

if (0 == $config['deploy']) {
$dbConfig = [
Expand All @@ -67,7 +69,9 @@ protected function getDbConfig(): array
];
}

$dbConfig['default_migration_table'] = $dbConfig['table_prefix'] . ($config['migration_table'] ?? 'migrations');
$table = $this->app->config->get('database.migration_table', 'migrations');

$dbConfig['default_migration_table'] = $dbConfig['table_prefix'] . $table;

return $dbConfig;
}
Expand Down
11 changes: 5 additions & 6 deletions src/command/migrate/Run.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class Run extends Migrate
protected function configure()
{
$this->setName('migrate:run')
->setDescription('Migrate the database')
->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to migrate to')
->addOption('--date', '-d', InputOption::VALUE_REQUIRED, 'The date to migrate to')
->setHelp(<<<EOT
->setDescription('Migrate the database')
->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to migrate to')
->addOption('--date', '-d', InputOption::VALUE_REQUIRED, 'The date to migrate to')
->setHelp(<<<EOT
The <info>migrate:run</info> command runs all available migrations, optionally up to a specific version
<info>php think migrate:run</info>
Expand All @@ -35,15 +35,14 @@ protected function configure()
<info>php think migrate:run -v</info>
EOT
);
);
}

/**
* Migrate the database.
*
* @param Input $input
* @param Output $output
* @return integer integer 0 on success, or an error code.
*/
protected function execute(Input $input, Output $output)
{
Expand Down

0 comments on commit e8b3396

Please sign in to comment.