I have coded a laravel package that I use in a Laravel app.
Both package and app have migrations, sometimes the same migration appears in both package and app, but content is different.
For example for the tournament table, in the package, in might be minimalistic, but for the app, there is a lot of fields.
Now, there is a bunch of migrations, so I don't want to publish them.
So, in the package, I added:
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
I have a problem running my tests:
PDOException: SQLSTATE[HY000]: General error: 1 no such table: ken_team
Which seams to be the only problematic table here.
I run sqlite in memory test, for faster results, and before each tests, laravel migrate, and then delete all scheme.
As I wondered the order of executing I put some debug string inside each up and down method from the app and the package.
The result is this:
up from app
up from package
down from package
down from app
Which is the expected result.
Now, inside a test
dump(DB::select('select * from sqlite_master where type="table"'));
Which will print all tables in sqlite scheme.
And I get:
29 => {#1020
+"type": "table"
+"name": "ken_team"
+"tbl_name": "ken_team"
+"rootpage": "77"
+"sql": "CREATE TABLE "ken_team" ("id" integer not null primary key autoincrement, "name" varchar not null, "championship_id" integer not null, "picture" varchar null, "entity_type" varchar null, "entity_id" integer null, "created_at" datetime null, "updated_at" datetime null, foreign key("championship_id") references "ken_championship"("id") on delete cascade on update cascade)"
Which confirms me that table exists just before test...
So why are my test failing ???
Aucun commentaire:
Enregistrer un commentaire