Add Not Nullable column to laravel migration with existing DB data

I have to add a new column to an existing table that already has data in it and running into a bit of a hiccup.

  1. How can I add this column? Its going to be a Not Nullable field. I'm ok with populating it with default data for right now and going back and updating later. so if we need to drop constraints while adding. I'm assuming I'm going to need to utilize straight SQL queries.

  2. Make this work w/ PHPUnit and SQLite, currently I'm getting an error SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL (SQL: alter table "tracks" add column "short_description" text not null)

How would I modify this migration?

public function up()
{
    Schema::table('tracks', function(Blueprint $table)
    {
        $table->text('short_description')->after('description');
    });
}

Answers


You have to set default value:

public function up()
{
    Schema::table('tracks', function(Blueprint $table)
    {
        $table->text('short_description')->after('description')->default('default_value');
    });
}

Need Your Help

What happens when BEFORE INSERT TRIGGER fails in oracle

oracle exception plsql triggers

I have a small doubt regarding BEFORE INSERT TRIGGER in oracle,

global variable is empty within function

jquery ajax variables global-variables scope

I have this code http://jsfiddle.net/meridius/ysDGm/ where the problem is with out.id variable in append part. For reasons I can't explain, that variable is empty in that part.