summaryrefslogtreecommitdiff
path: root/app/Console
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-12-02 19:16:50 -0500
committerFrederic Guillot <fred@kanboard.net>2016-12-02 19:16:50 -0500
commitf2fd5d75d98e01ab58a71b718d630b9b2ae8e16f (patch)
tree6c691b5f0024b822df75a37644e804c864d8f8e7 /app/Console
parentb5671a2dc04b63a8d7787b1137e72d7858955d98 (diff)
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
Diffstat (limited to 'app/Console')
-rw-r--r--app/Console/DatabaseMigrationCommand.php23
-rw-r--r--app/Console/DatabaseVersionCommand.php23
2 files changed, 46 insertions, 0 deletions
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 @@
+<?php
+
+namespace Kanboard\Console;
+
+use Kanboard\ServiceProvider\DatabaseProvider;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class DatabaseMigrationCommand extends DatabaseVersionCommand
+{
+ protected function configure()
+ {
+ $this
+ ->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 @@
+<?php
+
+namespace Kanboard\Console;
+
+use Kanboard\ServiceProvider\DatabaseProvider;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class DatabaseVersionCommand extends BaseCommand
+{
+ protected function configure()
+ {
+ $this
+ ->setName('db:version')
+ ->setDescription('Show database schema version');
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $output->writeln('<info>Current version: '.DatabaseProvider::getSchemaVersion($this->container['db']).'</info>');
+ $output->writeln('<info>Last version: '.\Schema\VERSION.'</info>');
+ }
+}