Skip to content

[5.0] Adds "--path" to the migrate:reset command #7884

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

Closed
wants to merge 1 commit into from
Closed

[5.0] Adds "--path" to the migrate:reset command #7884

wants to merge 1 commit into from

Conversation

chrisbjr
Copy link
Contributor

@chrisbjr chrisbjr commented Mar 5, 2015

Hi all,

I've added a --path option to the migrate:reset command.

Usage for this should be similar to the php artisan migrate --path="..." command.

So after doing the above command, you can do this:

php artisan migrate:reset --path="..."

I'm adding this because we have the option of doing a migration from a specified path but have no option to reset the migration from that path itself.

Hoping you consider this pull request.

Thanks
Chris

while (true)
{
$count = $this->migrator->rollback($pretend);
$count = $this->migrator->rollback($pretend, $path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indentation seems to be wrong.

@RomainLanz
Copy link

You change files permissions. Care about that.

@chrisbjr
Copy link
Contributor Author

chrisbjr commented Mar 6, 2015

@RomainLanz i missed some of those - just figured out that laravel doesn't follow PSR-2 coding style. Thanks for pointing those out.

@RomainLanz
Copy link

Laravel doesn't follow PSR-2 now, probably on the future.

Still dot missing on line 182.

@GrahamCampbell GrahamCampbell changed the title Adds "--path" to the migrate:reset command [5.0] Adds "--path" to the migrate:reset command Mar 6, 2015
@GrahamCampbell
Copy link
Member

Please squash to one commit.

@chrisbjr
Copy link
Contributor Author

chrisbjr commented Mar 7, 2015

Hi @GrahamCampbell done. Thanks!

$migrationEntries = [];
foreach ($files as $file)
{
// Remove the .php from the filenames
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should maybe just use glob in the first place?

@chrisbjr
Copy link
Contributor Author

chrisbjr commented Mar 7, 2015

@GrahamCampbell now using glob instead of scandir. Glob returns the full path of the files though but using basename did the trick. It even has a handy suffix parameter that can be used to remove the file extension.

Let me know if you're ok with it and I can squash to one commit again.

$files = glob($path . '/*.php');

$migrationEntries = [];
foreach ($files as $file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a new line before this block.

@chrisbjr
Copy link
Contributor Author

chrisbjr commented Mar 7, 2015

@GrahamCampbell moved

@GrahamCampbell
Copy link
Member

Thanks.

@taylorotwell
Copy link
Member

I'm not sure why this would be needed? migrate:reset should roll back all migrations.

@chrisbjr
Copy link
Contributor Author

chrisbjr commented Mar 8, 2015

Hi Taylor

Here is an example use case:

Let's say I wanted to install a Laravel package and it has its own migration files. Part of the instructions would be to migrate them using php artisan migrate --path="...".

But let's say we don't need the package anymore and wanted to remove only the migrations from that package without having to touch the main application's tables. Or another scenario would be that there was an updated migration file from the package. We don't want to reset the whole database just for this package.

In this case, we can use php artisan migrate:reset --path="..." and not touch the main tables. It makes sense to enable resetting from the path if we can migrate from a path.

@pilot911
Copy link
Contributor

good idea, also why we have only one hardcoded in config emailView for reset password ?
think those problems from one way - you Tailor should think wider about modularity

@taylorotwell
Copy link
Member

Going to hold off on this for now.

@clrke
Copy link

clrke commented Aug 25, 2015

+1 great feature but please redo it for 5.1

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling f7ce2d5 on chrisbjr:5.0 into * on laravel:5.0*.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants