In short: seeding is working fine with mysql while breaks with sqlite. The broken code is like DB::table('user')->insert($users);
Seed code:
<?php
public function run() {
DB::table('user')->delete();
$users = array();
$birth = new DateTime('1980-03-12');
while ($i++ < 50) {
$users[$i]['email'] = "[email protected]";
$users[$i]['password'] = User::password('test');
$users[$i]['enabled'] = 1;
$users[$i]['name'] = 'Name';
$users[$i]['surname'] = 'Surname';
$users[$i]['birthDate'] = $birth;
}
DB::table('user')->insert($users); //<- This line is broken when using sqlite.
}
My default database driver is mysql, now i am trying to switch to sqlite for the testing environment. So, under
app/config/testing/database.php
i have this config, inside 'connections' ('default' key is 'sqlite')
'sqlite' => array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
),
Now, if i issue
php artisan migrate --seed, this is working fine.
If i issue
php artisan migrate --seed --env=testing, this is NOT working
The DB::table('user')->insert($users);
above is failing, infact when i comment that out the seeding works fine.
The error at command line is
ErrorException","message":"array_keys() expects parameter 1 to be array, null given [...] /laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php","line":52
What's wrong here?