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

RefreshDatabaseFast is seeding before migrating. #8

Closed
manu144x opened this issue Oct 11, 2023 · 4 comments
Closed

RefreshDatabaseFast is seeding before migrating. #8

manu144x opened this issue Oct 11, 2023 · 4 comments

Comments

@manu144x
Copy link

I couldn't figure out why seeding was not working, but in the runMigrationsIfNecessary method of the Trait, you are first seeding (upon checking the configuration parameter, that's correct) but then you're doing a migrate fresh completely emptying the seeding :)

@Sairahcaz
Copy link
Member

Sairahcaz commented Nov 18, 2023

Please specify your issue more detailed, if you have further questions.
For instance give some example.

For now I'm gonna close this issue...

@stephenr85
Copy link

stephenr85 commented May 7, 2024

I believe this is in reference to RefreshDatabaseFast trait:

/**
     * Check if migration fresh is necessary by checking
     * if the migrations files checksum has changed.
     */
    protected function runMigrationsIfNecessary(): void
    {
        if (! $this->identicalChecksum()) {
            if (config('useful-additions.refresh_db_fast.seed')) {
                $this->seed();
            }

            $this->artisan('migrate:fresh', $this->migrateFreshUsing());

            //create checksum after migration finishes
            $this->createChecksum();
        }
    }

I'm not using this feature, but also noticed this while reading the code for another issue.

@holmesadam
Copy link

I too have come across this issue - but I am using the feature.

laracraft-tech/laravel-useful-additions/src/Traits/RefreshDatabaseFast.php:42

There is a check to see if the migrations need to run based on the checksum. With the config, you can have it seed too. However, the code seeds and then does a migrate fresh which effectively wipes out the seed. The seed should come after the migrate. See comment above for code block which I'm referring to.

@holmesadam
Copy link

I'm submitted a pull request to fix this #18

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

No branches or pull requests

4 participants