From f2fd5d75d98e01ab58a71b718d630b9b2ae8e16f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 2 Dec 2016 19:16:50 -0500 Subject: Add config parameter to toggle automatic SQL migrations - Add two command line opterations to show schema version and to execute SQL migrations - Add new configuration parameter to enable or disable SQL migrations --- app/Console/DatabaseMigrationCommand.php | 23 +++++++++++++++++++++++ app/Console/DatabaseVersionCommand.php | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 app/Console/DatabaseMigrationCommand.php create mode 100644 app/Console/DatabaseVersionCommand.php (limited to 'app/Console') diff --git a/app/Console/DatabaseMigrationCommand.php b/app/Console/DatabaseMigrationCommand.php new file mode 100644 index 00000000..252d4369 --- /dev/null +++ b/app/Console/DatabaseMigrationCommand.php @@ -0,0 +1,23 @@ +setName('db:migrate') + ->setDescription('Execute SQL migrations'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + DatabaseProvider::runMigrations($this->container['db']); + } +} diff --git a/app/Console/DatabaseVersionCommand.php b/app/Console/DatabaseVersionCommand.php new file mode 100644 index 00000000..5b1f1ed1 --- /dev/null +++ b/app/Console/DatabaseVersionCommand.php @@ -0,0 +1,23 @@ +setName('db:version') + ->setDescription('Show database schema version'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('Current version: '.DatabaseProvider::getSchemaVersion($this->container['db']).''); + $output->writeln('Last version: '.\Schema\VERSION.''); + } +} -- cgit v1.2.3