I am creating a new project to connect to an existing PostgreSQL database. I have successfully connected, and get get data, write to it, etc.
However, when it comes to running tests, they fail if they try to access the database.
Found 1 test(s).
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
E
======================================================================
ERROR: setUpClass (cylinders.tests.BatchProductModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python311\Lib\site-packages\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedTable: relation "locations" does not exist
LINE 1: INSERT INTO "locations" ("name", "alias", "loc_type", "creat...
^
It appears to create the test database okay, but it fails to find the table in there.
I ran the test with --keepdb, and took a look at the test database, and it has only the default tables in there; none of my models are there.
I guess an issue with migrations, which I just did not bother with at first, so after some research I did:
python manage.py makemigrations
python manage.py migrate --fake-initial
But still none of my tables in the test database. So where do I go from here?
[Not sure if “mystery errors” is the right place for this, but seems closer than the other options]