spatie / laravel-tags

Add tags and taggable behaviour to your Laravel app

Home Page:https://freek.dev/609-an-opinionated-tagging-package-for-laravel-apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing "down" method in create tag migration

jm-sky opened this issue · comments

After installing laravel-tags and trying to run artisan migrate:refresh I got error SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation "tags" already exists (SQL: create table "tags"

I've published the migrations file (...create_tag_tables.php), and I've found that there is no down method there.

I believe it should be something like that:

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('taggables');
        Schema::dropIfExists('tags');
    }

I'm just guessing here, but there's new best practices from a lot of laravel devs to not use down methods. It's cleaner to just create a new migration specifically for changing a model, rather than just rollback or whatever.

I've personally stopped using down methods myself in all my migrations.

edit: note some of spatie's packages if you vendor publish will publish the migration twice or multiple times if it already exists so you'll get a duplicate table error. make sure there aren't any other tags tables in migrations. Or you could drop('tags') before your latest tags migrations in the up() migrations.

Ok, thank You :-)