I don't understand this, I alter my table to add these columns
Schema::table('clusters', function($table)
{
$table->string('ssaEnabled',1)->default('0');
$table->string('ssaBackendUrl')->default(NULL);
$table->string('ssaPortalApiUrl')->default(NULL);
});
in my store() I have this
$cluster->ssaEnabled = Input::get('ssaEnabled','0');
$cluster->ssaBackendUrl = Input::get('ssaBackendUrl','');
$cluster->ssaPortalApiUrl = Input::get('ssaPortalApiUrl','');
$cluster->save();
I kept getting
prod.ERROR: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "ssaBackendUrl" violates not-null constraint
Why ??
- I set it to default null already
- I also add a backup value in my
Input::get()
in the 2nd param as an empty string
Any hints?
How can I stop that ?
CodePudding user response:
- Create a new migration
php artisan make:migration add_nullable_to_ssaBackendUrl_column_on_clusters_table --table=clusters
The
change
method allows you to modify the type and attributes of existing columns.
Schema::table('clusters', function($table)
{
$table->string('ssaBackendUrl')->nullable()->change();
});
- Run the migration
php artisan migrate