Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a reason why the spatie package laravel-tags has no down() function in migration

Tags:

laravel

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:

  1. Is there a reason not to deliver a down() function?
  2. What do I have to do to empty the new table?

Thanks in advance, Max

like image 261
Max Pattern Avatar asked Oct 18 '25 12:10

Max Pattern


1 Answers

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.

like image 130
Maik Lowrey Avatar answered Oct 22 '25 06:10

Maik Lowrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!