finchy70's avatar

All tests started failing.

I have 35 tests with 85 assertions that all were passing. The tests are done in an in memory database using DataBaseMigrations.

Every test now returns this error.

BadMethodCallException: SQLite doesn't support dropping foreign keys (you would need to re-create the table).

I have destroyed and re-upped my vagrant box (not that this would normally impact on in memory testing) but the errors still remain.

Also tried composer update.

Anyone else had this issue?

0 likes
2 replies
D9705996's avatar
D9705996
Best Answer
Level 51

Did you upgrade to laravel 5.7? The upgrade guide states

SQLite Foreign Keys

Likelihood Of Impact: Medium

SQLite does not support dropping foreign keys. For that reason, using the dropForeign method on a table now throws an exception. Generally, this should be considered a bug fix; however, it is listed as a breaking change out of caution.

If you run your migrations on multiple types of databases, consider using DB::getDriverName() in your migrations to skip unsupported foreign key methods for SQLite.

This is the error your getting, so look to add a conditional around any of your calls to dropForeign in you migrations

2 likes
finchy70's avatar

Thanks. I realised its due to me adding Voyager. The voyager migrations then break the tests. Not sure what to do with the migrations to stop the error so I decided to remove voyager and will reinstall it at the end of development I think.

Please or to participate in this conversation.