laravel/laravel — pull request #393 by ShawnMcCool (2012-03-07 19:55:56+00:00)
Title: made all sqlite fields nullable to fix various problems with the difference in sqlite's null functionality

DB Driver: SQLITE

// migration up
Schema::table('users', function($table)
{
$table->string('first_name');
$table->string('last_name');
});

$ php artisan migrate
SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL

SQL: ALTER TABLE "users" ADD COLUMN "first_name" VARCHAR NOT NULL

Bindings: array ()

// controller code

$user = new User;

$user->fill(array(
'email' => 'bob@bob.com',
'username' => 'cat'
));

$user->save();

// web error

Unhandled Exception
Message:

SQLSTATE[23000]: Integrity constraint violation: 19 users.real_name may not be NULL

SQL: INSERT INTO "users" ("email", "username", "updated_at", "created_at") VALUES (?, ?, ?, ?)

Bindings: array (
0 => 'bob@bob.com',
1 => 'cat',
2 => '2012-03-07 19:37:34',
3 => '2012-03-07 19:37:34',
)

Location:

D:\web\new-street-works\laravel\database\connection.php on line 200

Stack Trace:

#0 D:\web\new-street-works\laravel\database\connection.php(141): Laravel\Database\Connection->execute('INSERT INTO "us...', Array)
#1 D:\web\new-street-works\laravel\database\query.php(736): Laravel\Database\Connection->query('INSERT INTO "us...', Array)
#2 D:\web\new-street-works\bundles\eloquent\model.php(437): Laravel\Database\Query->insert_get_id(Array, NULL)
#3 D:\web\new-street-works\bundles\auth\models\user.php(48): Eloquent\Model->save()
#4 D:\web\new-street-works\application\controllers\home.php(17): User->save()
#5 [internal function]: Home_Controller->action_index()
#6 D:\web\new-street-works\laravel\routing\controller.php(241): call_user_func_array(Array, Array)
#7 D:\web\new-street-works\laravel\routing\controller.php(201): Laravel\Routing\Controller->response('index', Array)
#8 D:\web\new-street-works\laravel\routing\controller.php(80): Laravel\Routing\Controller->execute('index', Array)
#9 D:\web\new-street-works\laravel\routing\route.php(139): Laravel\Routing\Controller::call('home@index', Array)
#10 D:\web\new-street-works\laravel\routing\route.php(110): Laravel\Routing\Route->response()
#11 D:\web\new-street-works\laravel\laravel.php(173): Laravel\Routing\Route->call()
#12 D:\web\new-street-works\public\index.php(52): require('D:\web\new-stre...')
#13 {main}