From 34e988d221bee3beae2b8641d4144421f4b801b8 Mon Sep 17 00:00:00 2001 From: alexjoffroy Date: Sun, 8 Jan 2017 22:18:09 +0100 Subject: [PATCH] Install - Creates SQLite database if not existing --- src/Console/InstallCommand.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 6142e36..bc55f49 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -110,6 +110,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Setting up config files...'); $this->writeConfig($force); + $this->prepareDatabase(); + $output->writeln('Migrating database...'); $this->runProcess('php artisan october:up', 'Migrations failed!'); @@ -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("Creating $path ..."); + touch($path); + } + } + } }