Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 9 additions & 10 deletions src/Commands/Migration/Refresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ public function handle()

$this->eol()->info('Réinitialisation et réexécution des migrations...');

$group = $this->option('group', config('database.connection', 'default'));
$seed = $this->option('seed') === true;
$seed = $this->option('seed') === true;
$options = [
'--group' => $group = $this->option('group', config('database.connection', 'default')),
'--all' => $this->option('all') === true,
'--force' => $this->option('force') === true,
'--namespace' => $this->option('namespace'),
];

$this->newLine()->comment('Étape 1/2: Annulation de toutes les migrations');

$rollbackResult = $this->call('migrate:rollback', options: [
'--group' => $group,
'--all' => true,
'--force' => true,
]);
$rollbackResult = $this->call('migrate:rollback', options: $options);

if ($rollbackResult !== EXIT_SUCCESS) {
$this->error('Échec de l\'annulation des migrations.');
Expand All @@ -71,9 +72,7 @@ public function handle()

$this->newLine()->comment('Étape 2/2: Réexécution des migrations');

$migrateResult = $this->call('migrate', options: [
'--group' => $group,
]);
$migrateResult = $this->call('migrate', options: $options);

if ($migrateResult !== EXIT_SUCCESS) {
$this->error('Échec de l\'exécution des migrations.');
Expand Down
8 changes: 5 additions & 3 deletions src/Commands/Migration/Rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Rollback extends DatabaseCommand
*/
protected array $options = [
'-g, --group' => 'Groupe de base de données à utiliser',
'-n, --namespace' => 'Namespace spécifique à annuler',
'-b, --batch' => 'Numéro de lot cible (ex: 3 pour revenir au lot #3, -2 pour revenir de 2 lots)',
'--all' => 'Annuler toutes les migrations',
'--show-stats' => 'Afficher les statistiques de l\'opération',
Expand All @@ -55,8 +56,9 @@ public function handle()

$this->eol()->info('Recherche des migrations à annuler...');

$group = $this->option('group', config('database.connection', 'default'));
$batch = $this->option('all') ? 0 : $this->option('batch', 1);
$group = $this->option('group', config('database.connection', 'default'));
$namespace = $this->option('namespace');
$batch = $this->option('all') ? 0 : $this->option('batch', 1);

if (is_string($batch) && ! preg_match('/^-?\d+$/', $batch)) {
$this->error('Le numéro de lot doit être un entier.');
Expand All @@ -65,7 +67,7 @@ public function handle()
}
$batch = (int) $batch;

$runner = $this->runner('ALL', $group);
$runner = $this->runner($namespace ?? 'ALL', $group);

$rolledBack = 0;
$errorCount = 0;
Expand Down