aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2021-08-12 10:03:21 +0200
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2021-09-01 15:09:18 +0200
commit98be3c32ea9dd9fdce4616c9b1d425c8cb979309 (patch)
treed2d440cadb9367a13daae175d56c0bca93b0e54f /cli
parent8f1efe9394ed0a6d4822b43fc7b7c7e6ebebc90a (diff)
migration branches for 5.0
Diffstat (limited to 'cli')
-rwxr-xr-xcli/migrate.php21
-rwxr-xr-xcli/plugin_manager14
2 files changed, 17 insertions, 18 deletions
diff --git a/cli/migrate.php b/cli/migrate.php
index 2b43b17..0fe6bc3 100755
--- a/cli/migrate.php
+++ b/cli/migrate.php
@@ -17,14 +17,14 @@ require_once __DIR__ . '/studip_cli_env.inc.php';
if (isset($_SERVER['argv'])) {
# check for command line options
- $options = getopt('1:d:lm:t:v');
+ $options = getopt('b:d:lm:t:v');
if ($options === false) {
exit(1);
}
# check for options
- $single = false;
$domain = 'studip';
+ $branch = '0';
$list = false;
$path = $STUDIP_BASE_PATH . '/db/migrations';
$verbose = false;
@@ -32,8 +32,8 @@ if (isset($_SERVER['argv'])) {
foreach ($options as $option => $value) {
switch ($option) {
- case '1':
- $single = (string) $value;
+ case 'b':
+ $branch = (string) $value;
break;
case 'd':
$domain = (string) $value;
@@ -53,7 +53,9 @@ if (isset($_SERVER['argv'])) {
}
}
- $version = new DBSchemaVersion($domain);
+ DBSchemaVersion::validateSchemaVersion();
+
+ $version = new DBSchemaVersion($domain, $branch);
$migrator = new Migrator($path, $version, $verbose);
if ($list) {
@@ -61,15 +63,8 @@ if (isset($_SERVER['argv'])) {
foreach ($migrations as $number => $migration) {
$description = $migration->description() ?: '(no description)';
- printf("%3d %s\n", $number, $description);
- }
- } elseif ($single) {
- $direction = 'up';
- if ($single[0] === '-') {
- $direction = 'down';
- $single = substr($single, 1);
+ printf("%6s %-20s %s\n", $number, get_class($migration), $description);
}
- $migrator->execute($single, $direction);
} else {
$migrator->migrateTo($target);
}
diff --git a/cli/plugin_manager b/cli/plugin_manager
index 9a065fe..e566c75 100755
--- a/cli/plugin_manager
+++ b/cli/plugin_manager
@@ -132,18 +132,22 @@ if ($args) {
// show usage
if (!$pluginname) {
- echo 'Usage: '. $args[0] .' migrate PLUGINNAME [-l] [-t] [-v]' . "\n";
+ echo 'Usage: '. $args[0] .' migrate PLUGINNAME [-l] [-v] [-t target] [-b branch]' . "\n";
exit(1);
}
// parse options
- list($errors, $options, $args) = getopts(array('l' => 'Ss l list', 'v' => 'Ss v verbose', 't'=> 'Vs t target'));
+ list($errors, $options, $args) = getopts(array('l' => 'Ss l list', 'v' => 'Ss v verbose', 't' => 'Vs t target', 'b' => 'Vs b branch'));
$list = false;
$verbose = false;
$target = NULL;
+ $branch = '0';
foreach ($options as $option => $value) {
switch ($option) {
+ case 'b':
+ $branch = ($value === false) ? '0' : $value;
+ break;
case 'l':
$list = $value;
break;
@@ -166,7 +170,7 @@ if ($args) {
if (is_dir($plugindir . '/migrations')) {
// if there are migrations, migrate
- $schema_version = new DBSchemaVersion($plugin['name']);
+ $schema_version = new DBSchemaVersion($plugin['name'], $branch);
$migrator = new Migrator($plugindir . '/migrations', $schema_version, $verbose);
if ($list) {
@@ -175,7 +179,7 @@ if ($args) {
foreach ($migrations as $number => $migration) {
$description = $migration->description() ?: '(no description)';
- printf("%3d %-20s %s\n", $number, get_class($migration), $description);
+ printf("%6s %-20s %s\n", $number, get_class($migration), $description);
}
} else {
$migrator->migrateTo($target);
@@ -214,7 +218,7 @@ if ($args) {
if (is_dir($plugindir . '/migrations')) {
$schema_version = new DBSchemaVersion($plugin['name']);
$migrator = new Migrator($plugindir . '/migrations', $schema_version);
- $migrator->migrate_to(0);
+ $migrator->migrateTo(0);
}
echo 'Das Plugin '. $plugin['name'] .' wurde ausgetragen.' . "\n";