vendredi 30 juin 2017

Is there a easier way to set order of column when altering table in Laravel migration?

Let say I already got a table in my MySQL database, and I want to add columns to it. To do so, I am doing it like the following:

Schema::table('mytable', function($table) {
    $table->integer('my_special_integer')->after('previous_column');
    $table->text('my_special_text')->after('my_special_integer');
    $table->string('my_special_string')->after('my_special_text');
    /*Some many other field*/
    $table->string('my_last_column_to_add')->after('my_second_last_column');
}

Is there a less repeating way if I would simply like to input a bunch of column after a certain previous column?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire