I got the package laravel-tags from my favourite package provider spatie into the project to test it. After the first tests I wanted to empty the tables with php artisan migrate:refresh --seed to run further tests. But I get the exception:
SQLSTATE[HY000]: General error: 1 table "tags" already exists (SQL: create table "tags" ("id" integer not null primary key autoincrement, "name" text not null, "slug" text not null, "type" varchar, "order_column" integer, "created_at" datetime, "updated_at" datetime))
A look into the migration file showed me that there is no down() function of the migration of Spatie. So the data remains persistent and I can't start a rollback or reset. I don't like this at all. I added a down function munell, but even there I get the above exception. Hence my two questions:
Thanks in advance, Max
To your second question you can use php artisan db:wipe. That will drop all tables successfully.
To your first question:
Is there a reason not to deliver a down() function?
It is not standard to omit the down function in the migration. But why Spatie did it in this case I can only speculate. So it is hard to answer but good that you ask the question. Just add the down() function manually. After you have deleted the DB once, it should also work with the future rollbacks and resets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With