laravel-modules icon indicating copy to clipboard operation
laravel-modules copied to clipboard

delete command `module:migrate-fresh`

Open alissn opened this issue 1 year ago • 11 comments

Hi,

The migrate:fresh command in Laravel fully supports this functionality. This command executes migrate:fresh, followed by module:migrate (not need).

$this->call('migrate:fresh');

$this->call('module:migrate', [
    'module' => $this->getModuleName(),
    '--database' => $this->option('database'),
    '--force' => $this->option('force'),
    '--seed' => $this->option('seed'),
]);
     

alissn avatar Feb 06 '24 18:02 alissn

sorry, I'm not sure I understand?

dcblogdev avatar Feb 12 '24 01:02 dcblogdev

@dcblogdev The command module:migrate-fresh first executes migrate:fresh, which entails dropping all tables and then migrating all migrations from the root project and all module migrations.

Following that, it runs module:migrate with the argument module. The result is:

   INFO  Nothing to migrate.

On the other hand, all arguments that exist in migrate:fresh are also present in module:migrate.

Module Migrate Fresh Screenshot

alissn avatar Feb 13 '24 07:02 alissn

okay yes, that makes sense now. I'll merge it as part of the v11 release cycle.

dcblogdev avatar Feb 13 '24 19:02 dcblogdev

@solomon-ochepa

Hi! The command module:migrate-refresh does exactly what you want.

First, it runs module:migrate-reset, then it calls module:migrate, and finally, it executes module:seed for specific modules.

alissn avatar Feb 14 '24 20:02 alissn

@dcblogdev Did you take a look at this file? This command exists in the package.

You can find it here: https://github.com/nWidart/laravel-modules/blob/master/src/Commands/MigrateRefreshCommand.php

alissn avatar Feb 14 '24 21:02 alissn

@dcblogdev Did you take a look at this file? This command exists in the package.

You can find it here: https://github.com/nWidart/laravel-modules/blob/master/src/Commands/MigrateRefreshCommand.php

That is the same file you were asking to be removed.

I believe we can close this PR now and maintain the updated file.

solomon-ochepa avatar Feb 15 '24 05:02 solomon-ochepa

That is the same file you were asking to be removed.

this PR delete src/Commands/MigrateFreshCommand.php file. it's different with src/Commands/MigrateRefreshCommand.php

alissn avatar Feb 15 '24 16:02 alissn

That is the same file you were asking to be removed.

this PR delete src/Commands/MigrateFreshCommand.php file. it's different with src/Commands/MigrateRefreshCommand.php

Both commands should be maintained. There is a reason why even the Laravel framework maintains both commands.

Nevertheless, the module:migrate-fresh command should run within the scope of the targeted module only; otherwise it should be updated. And if there is no means, we can proceed with deleting it.

The project aims to replicate the core Laravel structure, commands and workflow in a modular architecture.

solomon-ochepa avatar Mar 17 '24 03:03 solomon-ochepa

I think for the sake of compatibility, we could update MigrateFreshCommand to call refresh ie

$this->call('module:migrate-refresh', [
    'module' => $this->getModuleName(),
    '--database' => $this->option('database'),
    '--force' => $this->option('force'),
    '--seed' => $this->option('seed'),
]);

dcblogdev avatar Apr 17 '24 07:04 dcblogdev

Closed, going to restrict module:migrate-fresh to reset only selected modules this way its only in the scope of the module and not the whole application.

dcblogdev avatar Apr 24 '24 20:04 dcblogdev