cviebrock / eloquent-taggable

Easily add the ability to tag your Eloquent models in Laravel.
MIT License
537 stars 72 forks source link

Error in migration when using postgres. #122

Closed 0528Makoto closed 3 years ago

0528Makoto commented 3 years ago

Description:

Then migration Migrating: 2021_03_30_111045_create_taggable_table gives an error when using the postgres with Laravel. Running php artisan migrate on a fresh installation gives the following error.

Illuminate\Database\QueryException  : SQLSTATE[42704]: Undefined object: 7 ERROR:  collation "utf8_bin" for encoding "UTF8" does not exist at character 128 (SQL: create table "taggable_tags" ("tag_id" bigserial primary key not null, "name" varchar(255) not null, "normalized" varchar(255) collate "utf8_bin" not null, "created_at" timestamp(0) without time zone null, "updated_at" timestamp(0) without time zone null))

Steps To Reproduce:

  1. Fresh installation of laravel
  2. Change .env to use postgres as driver
  3. Add cviebrock/eloquent-taggable as dependency
  4. php artisan migrate
cviebrock commented 3 years ago

Ok, so this is an issue with Postgres not supporting the utf8_bin collation? Or something else? I'm not super familiar with Postgres specifics.

We need to specify some binary collation here, otherwise (as you can see from the PR) the test fails when normalizing strings with accents (see https://github.com/cviebrock/eloquent-taggable/blob/master/tests/TaggingTests.php#L303-L314).

Can you suggest an alternate fix that still works with that test?

0528Makoto commented 3 years ago

add a small change for the tests to pass, but it would be necessary to test in other drivers (sqlserver, sqlite)

cviebrock commented 3 years ago

Merged and bumped the version. I'll have to spend a bit more time to make sure this works with the other drivers. Thanks!!