#21856 closed Bug (fixed)

Crash when DATABASES = {}

Reported by: aaugustin Owned by: andrewgodwin
Component: Migrations Version: master
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As of 1d20e6df9553346c79edd92e6e8934e9c5c4aa2c it isn't possible to run Django with DATABASES = {} any more.

Change History (6)

comment:1 Changed 19 months ago by mlavin

  • Has patch set

I've sent a PR to fix this issue: https://github.com/django/django/pull/2244 This moves the check for unapplied migrations out of the runserver command and uses the new system checks framework instead.

comment:2 Changed 19 months ago by Andrew Godwin <andrew@…>

  • Owner set to Andrew Godwin <andrew@…>
  • Resolution set to fixed
  • Status changed from new to closed

In 38b4adc6960d28483124509aa363dadbe8cc17a6:

Merge pull request #2244 from mlavin/21856-migration-checks

Fixed #21856: Allow Empty DATABASES Setting

comment:3 Changed 19 months ago by ryankask

  • Resolution fixed deleted
  • Status changed from closed to new

When running the tests, I am getting a warning from the new check command:

 ./manage.py test
Creating test database for alias 'default'...
System check identified some issues:

WARNINGS:
?: You have unapplied migrations; your app may not work properly until they are applied.
        HINT: Run 'python manage.py migrate' to apply them.
.
----------------------------------------------------------------------
Ran 1 test in 0.008s

OK
Destroying test database for alias 'default'...

But notice no warnings are emitting when just running check:

$ ./manage.py check
System check identified no issues (0 silenced).

It seems confused because the checks are running before the tests are migrated.

I think it has something to do with this commit: https://github.com/django/django/commit/0ac13eccebb3d879f79b31585b1e81f655067179

comment:4 Changed 19 months ago by mlavin

I wasn't seeing this when running the Django test suite. I see this warning is also issued when you run migrate from #22031 which isn't wanted. I don't agree with the resolution that this doesn't belong in the checks framework. This fits precisely into its stated purpose.

The system check framework is a set of static checks for validating Django projects. It detects common problems and provides hints for how to fix them.

There should be a way to suppress this check when it is not known to not be relevant such was when running migrate.

comment:5 Changed 19 months ago by andrewgodwin

  • Owner changed from Andrew Godwin <andrew@…> to andrewgodwin
  • Status changed from new to assigned

On the contrary, I think this is only relevant when running runserver - not having applied migrations is a valid state for a Django project and is only really of concern if you are trying to run the website and interact with it (and even then you might want it).

I'm going to move it back from being a check and fix it a different way.

comment:6 Changed 19 months ago by Andrew Godwin <andrew@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In f0f1ba75b090e533c1b39f516cea2d9a15307ac3:

Fixed #21856: Don't crash runserver when DATABASES = {}

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