Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Migration change length of existed column

Tags:

laravel

It not work, I search so many ways, How can I change length of value in laravel 5

public function up() {     Schema::table('articles', function (Blueprint $table) {         $table->string('name',50)->change();     }); } 

Thank you all for reading!

like image 740
Sang Trần Avatar asked Apr 07 '16 07:04

Sang Trần


People also ask

How do I change the length of a column in laravel?

To modify a column with a foreign key constraint, you'll have to use alter table [table] modify (i.e. DB::statement('alter table [table] modify [column] [changes]');).

How do I change a column to unique in laravel migration?

$table->unique('slug'); So you add unique index to existing 'slug'.

How do I change column name and data type in laravel migration?

Following worked for me. Definitely you need to install doctrine/dbal to make this work, using following command in terminal. open your migration file and write down below. Schema::table('yourTable', function (Blueprint $table) { $table->string('column_name','4294967295')->change(); });


1 Answers

Regarding documentation, your example should work:

Schema::table('users', function ($table) {     $table->string('name', 50)->change(); }); 

Just run php artisan migrate command to execute it.

like image 116
Alexey Mezenin Avatar answered Sep 18 '22 16:09

Alexey Mezenin