Skip to content

Commit

Permalink
Merge pull request #5 from alexjoffroy/master
Browse files Browse the repository at this point in the history
Install - Creates SQLite database if not existing
  • Loading branch information
tobias-kuendig authored Jan 10, 2017
2 parents 2de3b35 + 34e988d commit f574396
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('<info>Setting up config files...</info>');
$this->writeConfig($force);

$this->prepareDatabase();

$output->writeln('<info>Migrating database...</info>');
$this->runProcess('php artisan october:up', 'Migrations failed!');

Expand Down Expand Up @@ -226,4 +228,19 @@ protected function cleanup()
@unlink(getcwd() . DS . $file);
}
}

/**
* Prepare database before migrations.
*/
public function prepareDatabase()
{
// If SQLite database does not exist, create it
if ($this->config->database['connection'] === 'sqlite') {
$path = $this->config->database['database'];
if (!file_exists($path) && is_dir(dirname($path))) {
$this->output->writeln("<info>Creating $path ...</info>");
touch($path);
}
}
}
}

0 comments on commit f574396

Please sign in to comment.