Skip to content

Commit

Permalink
fix: remove -g option in migrate:rollback
Browse files Browse the repository at this point in the history
Rollback specifies a batch number and returns the database to that state.
It is not possible to specify a specific group to return to a state.
  • Loading branch information
kenjis committed Sep 4, 2023
1 parent 294b19c commit 096b23a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
6 changes: 0 additions & 6 deletions system/Commands/Database/MigrateRollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class MigrateRollback extends BaseCommand
*/
protected $options = [
'-b' => 'Specify a batch to roll back to; e.g. "3" to return to batch #3',
'-g' => 'Set database group',
'-f' => 'Force command - this option allows you to bypass the confirmation question when running this command in a production environment',
];

Expand All @@ -79,11 +78,6 @@ public function run(array $params)
}

$runner = Services::migrations();
$group = $params['g'] ?? CLI::getOption('g');

if (is_string($group)) {
$runner->setGroup($group);
}

try {
$batch = $params['b'] ?? CLI::getOption('b') ?? $runner->getLastBatch() - 1;
Expand Down
10 changes: 3 additions & 7 deletions system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ public function latest(?string $group = null)
*
* Calls each migration step required to get to the provided batch
*
* @param int $targetBatch Target batch number, or negative for a relative batch, 0 for all
* @param int $targetBatch Target batch number, or negative for a relative batch, 0 for all
* @param string|null $group Deprecated. The designation has no effect.
*
* @return mixed Current batch number on success, FALSE on failure or no migrations are found
* @return bool True on success, FALSE on failure or no migrations are found
*
* @throws ConfigException
* @throws RuntimeException
Expand All @@ -233,11 +234,6 @@ public function regress(int $targetBatch = 0, ?string $group = null)
throw ConfigException::forDisabledMigrations();
}

// Set database group if not null
if ($group !== null) {
$this->setGroup($group);
}

$this->ensureTable();

$batches = $this->getBatches();
Expand Down
3 changes: 1 addition & 2 deletions user_guide_src/source/dbmgmt/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,14 @@ to minimize any potential conflicts between the main application and any modules
rollback
========

Rolls back all migrations, taking the database group to a blank slate, effectively migration 0:
Rolls back all migrations to a blank slate, effectively migration 0:

.. code-block:: console
php spark migrate:rollback
You can use (rollback) with the following options:

- ``-g`` - to choose database group, otherwise default database group will be used.
- ``-b`` - to choose a batch: natural numbers specify the batch.
- ``-f`` - to force a bypass confirmation question, it is only asked in a production environment.

Expand Down

0 comments on commit 096b23a

Please sign in to comment.