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

[11.x] Do not wipe database if it does not exists #50838

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

driesvints
Copy link
Member

@driesvints driesvints commented Mar 29, 2024

If the migrate:fresh command is called while there isn't any database created yet, it'll fail when it tries to wipe the database. This PR fixes this by first checking if the migrations table exists and if not, immediately go to the migrate command by skipping the db:wipe command. This will invoke the migrate command flow and subsequently will reach the point where the command will ask the user to create the database.

In combination with #50836 this will offer a more seamless experience for people attempting to install Jetstream through the Laravel installer and choosing to not create the database.

Screenshot 2024-03-29 at 12 23 26

@driesvints driesvints changed the title Do not wipe database if it does not exists [11.x] Do not wipe database if it does not exists Mar 29, 2024
@driesvints driesvints marked this pull request as draft March 29, 2024 11:26
@driesvints driesvints marked this pull request as ready for review March 29, 2024 11:29
@taylorotwell taylorotwell merged commit 679cb58 into 11.x Mar 29, 2024
29 checks passed
@taylorotwell taylorotwell deleted the upgrade-fresh-command branch March 29, 2024 14:37
@streamingsystems
Copy link

streamingsystems commented Apr 4, 2024

Hi All,

I use Laravel Lumen and have my own fork that upgraded to the Laravel 11 Framework (the standard repo goes up to 10). I believe that Lumen is not officially supported but I am sure there are a lot of folks out there (like me) that still use it.

Anyhow, when I upgraded today to 11.2.0 it blew me up:

In FreshCommand.php line 45:

Too few arguments to function Illuminate\Database\Console\Migrations\FreshCommand::__construct(), 0 passed in /home/ss/application-origin/vendor/laravel/lume
n-framework/src/Console/ConsoleServiceProvider.php on line 211 and exactly 1 expected

It looks like this fix changed the constructor and instead of using the Command base class constructor (which was an empty constructor) it now requires a Migrator.

I had to change this:

protected function registerMigrateFreshCommand()
    {
        $this->app->singleton('command.migrate.fresh', function () {
            return new MigrateFreshCommand;
        });
    }                                                         
            

to this:

protected function registerMigrateFreshCommand()
    {
        $this->app->singleton('command.migrate.fresh', function ($app) {
            return new MigrateFreshCommand($app['migrator']);
        });
    }       

And it fixed it.

I was more writing this to let you know that other folks that have Laravel Lumen that is using the Laravel 11 framework it will blow them up. Not sure if you can make that constructor backwards compatible.

Thanks!

-Rob

@driesvints
Copy link
Member Author

Thanks @streamingsystems. We're currently prepping Lumen v11. I've added this change to it.

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.

4 participants