samedi 28 mars 2020

Can't apply migrations in Django SQLlite memory database

I'm writing some tests, and I want to be able to run django server with my test settings (that's why I'm using in-memory database).

It seems to be working, no errors reported when running. But migrations are not applied - I can't perform any action on the database, because model tables do not exist.

When I run python manage.py migrate, all my migrations get applied (I see these Applying migrations... OK messages), but it has no effect. When I run python manage.py showmigrations, none of the migrations are applied (I see [ ] 0001_initial etc., without the X).

When I go to django shell, I can't perform any action, because table does not exist. Any idea what might be the reason? It works fine with normal, postgres database.

My settings:

DEBUG = True

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': ':memory:',
        'TEST_NAME': ':memory:',
    },
}

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': ''
    }
}

Aucun commentaire:

Enregistrer un commentaire