I want to use SQLite for PHPunit tests. We are using the mysql
driver, so we have created our migrations based on that... meaning we are using nullables
for default values. MYSQL
doesn't care about this. SQLite
, apparently, does.
Migrations:
Schema::table('users', function ($table) {
$table->string('username', 132)->nullable();
TestCase snippet: configuring phpunit environment
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
]
Running phpunit
outputs:
Cannot add a NOT NULL column with default value NULL
I noticed there was a "STRICT" mode for mysql
in the database.php
configuration file that you can set to false
which handles invalid or missing data types:
'mysql' => [
'driver' => 'mysql',
...
'strict' => false,
],
So I started looking for a strict
mode for SQLite and found Strict Mode here, tried setting PRAGMA strict=ON;
to off
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
'strict' => false
]
But this did not fix it.
Is there a way to set SQLite to ignore nullable()
values set in migrations (aimed at mysql configurations) so I can run my unit tests quickly with SQLite in memory?
My alternatives are:
- remove all
nullable()
options for migrations and add defaults, which will take forever - use mysql instead of sqlite, which will be much slower
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Nz5Mkl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire