DarkGhostHunter/Laraguard

Can't run migration: index name too long

Closed this issue · 4 comments

Grldk commented
  • Laravel Version: 6.14.0
  • PHP Version: 7.3
  • Database Driver & Version: MySQL 5.7.27

When running included migration I get the following error:

SQLSTATE[42000]: Syntax error or access violation: 
1059 Identifier name 'two_factor_authentications_authenticatable_type_authenticatable_id_index' is too long 
(SQL: alter table `two_factor_authentications` add index `two_factor_authentications_authenticatable_type_authenticatable_id_index`(`authenticatable_type`, `authenticatable_id`))

A shorter index name here should fix this I guess?

MySQL has a limit of 64, MariaDB of 80, PostgreSQL has 63 and truncates, and SQL Server has 128. SQLite doesn't care as long you don't go overboard the query characters limit.

Yeah, that seems like a long index. I will use this once I out my hands on the computer. The morphs method creates an index automatically, but AFAIK you can just go manual and do it yourself.

Lol, you can add the index name to the morph() method. It should be fixed on the next release.

Good news: is fixed.

Bad news: Laravel 6.15 includes the Validated event, which makes the whole thing error. Unless I refactor the package to handle both events (Attempting and Validated), this gonna take a while.

Damn. I'll have to (again) take down the package for a simple reason: I can't test if a class doesn't exists. Major rework is needed.

I deeply sorry for all headaches caused, but for sanity purposes I will make the rewrite easier and only compatible with Laravel 6.15+.