[Answered ]-Unit tests with an unmanaged external read-only database

2👍

After a day of staring at my screen, I found a solution:

I removed the managed=True from the models, and generated migrations. To prevent actual migrations against the production database, I used my database router to prevent the migrations. (return False in allow_migrate when for the appropriate app and database).

In my settings I detect whether unittests are being run, and then just don’t define the database router or the external database. With the migrations present, the unit tests.

Leave a comment