I created a migration to update the size of a VARCHAR column in MySQL and to rename it in the same migration. So to change a VARCHAR() type through Laravel Schema we use string() base on Laravel docs
This is the function up():
Schema::table('address', function (Blueprint $table) {
$table->string('place_id', 100)->change();
$table->renameColumn('place_id', 'full_address');
});
and the function down():
Schema::table('address', function (Blueprint $table) {
$table->string('full_address', 255)->change();
$table->renameColumn('full_address', 'place_id');
});
It is renaming the column but it is not changing the size, any ideas why?.
MySQL table
Field, table, Type, Character Set, Display Size
place_id,address,VARCHAR,utf8,255
Thank you in advance.
php artisan ...command you're running? - Tim Lewisphp artisan migrate, andmigrate:rollback. I dunno if it's possible to change the size and rename the column in the same migration. - CarlosZmigrateand before you runmigrate:rollback? - James CookSchema::defaultStringLength(191);See stackoverflow.com/a/23786522/470749 and laravel-news.com/laravel-5-4-key-too-long-error - Ryan