I have create a table stack_links as below
Schema::create('stack_links', function (Blueprint $table) {
$table->increments('id');
$table->string('site_key');
$table->string('url');
$table->string('path_run')->nullable();
$table->integer('state');
$table->integer('parent')->nullable();
$table->text('data');
$table->timestamps();
$table->unique(['site_key', 'url']);
$table->index(['site_key']);
$table->index(['state']);
$table->index(['parent']);
$table->index(['url']);
});
Now i want to change url column to text type. So i have tried this
$table->text('url')->change();
Hower it return this err
1170 BLOB/TEXT column 'url' used in key specification without a key length
After searching, i found that the err because url is indexed(MySQL error: key specification without a key length). So i remove index but it still the same err. i follow : https://laravel.com/docs/5.5/migrations#dropping-indexes
Schema::table('stack_links', function (Blueprint $table) {
$table->dropUnique(['url']);
$table->dropIndex(['url']);
$table->text('url')->change();
$table->string('md5_url');
$table->unique('md5_url');
$table->index('md5_url');
});
Can anyone tell me where am i wrong.
Update : The problem is the parameter of dropIndex. When i replace it with the name of index. It work
uniqueon thaturlis going to be super costly for you in the future if you start dealing with tons of records. Now, regarding your problem, you absolutely must use alengthon atextcolumn when you want it to be anindex. so...$table->text('url', 1024)->change()for instance.