Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#34398 closed Bug (invalid)

Django should automatically run migrations on in-memory SQLite DB

Reported by: Yawar Quadir Amin Owned by: nobody
Component: Database layer (models, ORM) Version: 4.1
Severity: Normal Keywords: sqlite
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When we use an in-memory SQLite database (for example when running tests or other purposes), it seems that it's not possible to run the migrations in a normal way because the in-memory database won't exist in the process run by python manage.py migrate.

Im this case Django should recognize the restriction and run the migrations automatically.

Change History (4)

comment:1 by Mariusz Felisiak, 21 months ago

Resolution: invalid
Status: newclosed

Migrations are run automatically when using an in-memory SQLite database to run the tests. If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.

comment:2 by Yawar Quadir Amin, 21 months ago

OK good to know about the tests. But I'm not just talking about the tests. If we set up SQLite in-memory database as the 'live' Django database, it should also run the migrations automatically, no?

in reply to:  2 comment:3 by Mariusz Felisiak, 21 months ago

Replying to Yawar Quadir Amin:

If we set up SQLite in-memory database as the 'live' Django database, it should also run the migrations automatically, no?

I'm not sure how you use SQLite in-memory database in production, but if you do this you need to handle migrations on your own. For example, by calling call_command("migrate", ...) in your scripts.

comment:4 by Yawar Quadir Amin, 21 months ago

We can use SQLite in-memory DB in production because our database of record is maintained by another backend service, and the Django app is just calling out to that service to authenticate users. So the Django DB doesn't really matter, it's just a local cache.

Anyway, we will use a temp file for now since Django seems to not worry about this use case ;-)

Note: See TracTickets for help on using tickets.
Back to Top