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

[Bug] Refresh command command not working with filtered tables #84

Open
kennaar opened this issue Feb 20, 2019 · 1 comment
Open

[Bug] Refresh command command not working with filtered tables #84

kennaar opened this issue Feb 20, 2019 · 1 comment

Comments

@kennaar
Copy link

kennaar commented Feb 20, 2019

Hi,

I'm trying to use the refresh command to rollback and migrate my database. I have a migration for a password_resets table.
When I run the refresh command, internally it calls the reset command and it doesn't drop the password_resets table because I have it in my migrations.schema.filter regex listed.
Then the refresh command calls the migrate command and it tries to create the password_resets table because this command doesn't account for the filter.

Removing it from the filter regex also isn't any good because then the diff command generates a migration to drop the table every time.

I think I'm doing something wrong like I should provide an extra option when running the command, but there doesn't seem to be any option.

Thanks in advance

@SPie
Copy link
Contributor

SPie commented Mar 7, 2019

You can use the Builder::hasTable($tableName) method so you only create a table if it doesn't exist already.

public function up(Schema $schema)
{
    $builder = new Builder($schema);
    if (!$builder->hasTable('password_reset')) {
        $builder->create('password_reset', function (Table $table) {
            // create table
        });
    }
}

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

2 participants