php - Add Not Nullable column to laravel migration with existing DB data -
i have add new column existing table has data in , running bit of hiccup.
how can add column? going
not nullable
field. i'm ok populating default data right , going , updating later. if need drop constraints while adding. i'm assuming i'm going need utilize straight sql queries.make work w/ phpunit , sqlite, i'm getting error
sqlstate[hy000]: general error: 1 cannot add not null column default value null (sql: alter table "tracks" add column "short_description" text not null)
how modify migration?
public function up() { schema::table('tracks', function(blueprint $table) { $table->text('short_description')->after('description'); }); }
you have set default value:
public function up() { schema::table('tracks', function(blueprint $table) { $table->text('short_description')->after('description')->default('default_value'); }); }
Comments
Post a Comment