Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Migration Error #284

Open
udoyen opened this issue May 31, 2017 · 5 comments
Open

Database Migration Error #284

udoyen opened this issue May 31, 2017 · 5 comments
Labels

Comments

@udoyen
Copy link

udoyen commented May 31, 2017

I see this error:

"SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'name' used in key specification without a key length"

When I try to run the artisan command: php artisan migrate --database=tracker following the setup tutorial.
tracker_error.txt

@antonioribeiro
Copy link
Owner

If you execute

php artisan tracker:tables

And then

php artisan migrate

Does it works?

@Antipov007
Copy link

I have same problem. No it still not works((
MySQL 5.7

C:\OpenServer\modules\php\PHP-7-x64\php.exe C:\OpenServer\domains\newbean\artisan tracker:tables
Generating optimized class loader
The compiled services file has been removed.

Process finished with exit code 0 at 00:13:28.
Execution time: 4 913 ms.

C:\OpenServer\modules\php\PHP-7-x64\php.exe C:\OpenServer\domains\newbean\artisan migrate
"SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'name' used in key specification without a key length (SQL: alter table tracker_agents add unique tracker_agents_name_unique(name))"

Process finished with exit code 1 at 00:13:41.
Execution time: 2 350 ms.

@Antipov007
Copy link

WOW FOUND DECISSION!!!! THIS IS REPOST:

nipun5perera commented on 25 Feb

I did edit create_tracker_agents_table.php and changed ,

$table->string('name')->unique();

to

$table->string('name',255);

and then added

$table->unique('name');

so my create would look like this,

$table->bigIncrements('id');
$table->string('name',255);
$table->string('browser')->index();
$table->string('browser_version');
$table->timestamp('created_at')->index();
$table->timestamp('updated_at')->index();
$table->unique('name');

and then edited fix_agent_name.php and changed

$table->mediumText('name')->unique()->change();

to

$table->string('name',255)->unique()->change();

for me this solved that key length problem and everything migrated successfully.

@antonioribeiro
Copy link
Owner

It was changed from string 255 to mediumText because 255 is not enough sometimes.

I'm changing the index to a hash of this mediumText, please be patient.

@Antipov007
Copy link

ok, thanks man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants