Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: spark migrate -g option #7894

Merged
merged 8 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove -g option in migrate:rollback
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 5, 2023
commit 710649f57f3f46ae68ce3e4274d87bfad01a62cb
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