Migration change only the default value of a field - Laravel

Asked

Viewed 1,150 times

0

I want to launch a migration that updates only the default value of a field, I tried it as follows :

 $table->string('mikrotik_rate_limit')->default('1048576/1048576');
 $table->bigInteger('mikrotik_recv_limit')->default(1073741824);
 $table->bigInteger('mikrotik_xmit_limit')->default(1073741824);

but it didn’t work because obviously the field already exists so he understood that I wanted to create a new one so he gave duplicate field alert. I wonder how I can fix that

1 answer

1


Basically something similar should be done to an alter table of sql. In the documentation of the Laravel has a guide for this: modifying columns. Basically you create a Migration and add the change() function in the example you put:

$table->string('mikrotik_rate_limit')->default('1048576/1048576')->change();
$table->bigInteger('mikrotik_recv_limit')->default(1073741824)->change();
$table->bigInteger('mikrotik_xmit_limit')->default(1073741824)->change();

To do this you must add Doctrine/dbal to your Composer.json and run the installation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.