rtconner / laravel-tagging

Tag support for Laravel Eloquent models - Taggable Trait
MIT License
882 stars 168 forks source link

create_tags_table migration broken in v3.3.0 #182

Closed Levivb closed 4 years ago

Levivb commented 4 years ago

Hey RtConner,

in your latest tag of about half an hour ago a change was made in src/Providers/TaggingServiceProvider.php which breaks existing (older) applications which have been using your package for a while.

Offending commit: https://github.com/rtconner/laravel-tagging/commit/c1786d5bbd8d5973946c8f2792769b1c2cb2a6b8#diff-1805f4a38431eac691e92bfe44a98bbc

Previously, one had to publish the migrations in order to run them. Now, the migrations are ran directly from the package. Which is fine in and of itself. The problem arises due to this diff: https://github.com/rtconner/laravel-tagging/compare/3.2.0...3.2.1

In which an existing and historically already ran migration is changed: 2014_01_07_073615_create_tags_table.php

2016_06_29_073615_update_tags_table, however, is never ran by us. so we don't have tag_group_id column. That 2016_06_29_073615_update_tags_table migration however expects the column to exist. Prior (in the same 3.2.0 <> 3.2.1 diff) the tag_group_id was created in 2016_06_29_073615_update_tags_table.php. But now it should have been created in 2014_01_07_073615_create_tags_table which isn't the case for use since we ran the old version of that migration.

Can you apply a hotfix so these migrations aren't causing issues?

Possible solutions I can think of right now:

  1. Rollback the move of $table->integer('tag_group_id')->unsigned()->nullable()->after('id');
  2. Add a column exists check in 2016_06_29_073615_update_tags_table

error:


Migrating: 2016_06_29_073615_update_tags_table

   Illuminate\Database\QueryException  : SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'tag_group_id' doesn't exist in table (SQL: alter table `tagging_tags` add constraint `tagging_tags_tag_group_id_foreign` foreign key (`tag_group_id`) references `tagging_tag_groups` (`id`))```
rtconner commented 4 years ago

Arg, really sorry about this. Thank you for reporting. I just switched to use the new loadMigrationsFrom feature. I did not realize it had this side effect.

I've deleted version 3.3 and did a major version on this change with 4.0

Levivb commented 4 years ago

Ow, that's a solution as well off-course 👍 Thanks for the quick fix

A bit silly off us to have a package this old in an un-updated state though. Since the tagging isn't used by our clients we are going to retire the functionality anyway.

faridsh69 commented 4 years ago

I have this problem on version 4

Levivb commented 4 years ago

@faridsh69 yea, the issue isn't 'fixed' in and of itself. The difference is that the change has become a major version bump which means your software should account for any breaking changes upon updating the dependency. In this case you should add a separate migration to prepare for the upgrade of this package.