I switched to using a testing database so it's identical and it works.
If you have the answer to the original question feel free to post it and I will mark it as best for history purposes.
My Unit test fails with this
Failed asserting that a row in the table [pages] does not match the attributes {
"page": 1
}.
Correct, it is in there. Now if I delete the Book which has this hasMany from my dev environment it works fine. migration:
Schema::create('books', function (Blueprint $table)
{
$table->bigIncrements('id');
$table->string('name');
$table->timestamps();
});
Schema::create('pages', function (Blueprint $table)
{
$table->bigIncrements('id');
$table->unsignedBigInteger('book_id');
$table->text('content');
$table->integer('page');
$table->timestamps();
});
Schema::table('pages', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->foreign('book_id')->references('id')->on('books')->onDelete('cascade');
});
It works fine from my dev environment using mariadb, the unit test using sqlite fails. Why is this?
I have this too
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
Please or to participate in this conversation.