Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#23808 closed Bug (fixed)

manage.py runserver creates django_migrations without concent

Reported by: jorgecarleitao Owned by: nobody
Component: Documentation Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When you run ./manage.py runserver on a database without django_migrations table, the command issues a CREATE to create the table.

While this seems natural for users trying to run the server the first time, I would not expect a database interaction (specially a CREATE statement) from a runserver. The user is not being informed that the database is being changed.

At least, this should be mentioned in the documentation, but IMO it is odd that a runserver is issuing CREATE statements.

Of course, this is a consequence of not running manage.py migrate before.

Change History (8)

comment:1 by Andreas Madsack, 10 years ago

Triage Stage: UnreviewedAccepted

reproduceable on trunk

comment:2 by Andreas Madsack, 10 years ago

The MigrationRecorder seems to create the table if it doesn't exist.

see: https://github.com/django/django/blob/master/django/db/migrations/recorder.py#L43

comment:3 by Markus Holtermann, 10 years ago

Component: MigrationsDocumentation
Needs documentation: set

I don't see a reasonable way to prevent Django from creating this table. But you are right, this should be documented.

comment:4 by Andreas Madsack, 10 years ago

Needs documentation: unset

comment:5 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 27c9b3a27d313e75732c1e8e966b320ddbde499d:

Fixed #23808 -- Documented that migrations table is created when using runserver without migrating first.

comment:6 by Tim Graham <timograham@…>, 10 years ago

In 7796f62c36555569125f8bb00cfb8b84b6da4eec:

[1.7.x] Fixed #23808 -- Documented that migrations table is created when using runserver without migrating first.

Backport of 27c9b3a27d313e75732c1e8e966b320ddbde499d from master

comment:7 by Marti Raudsepp, 8 years ago

Discussion for an alternative solution here: #27858

Last edited 8 years ago by Marti Raudsepp (previous) (diff)

comment:8 by Tim Graham <timograham@…>, 7 years ago

In fda55c71:

Fixed #27858 -- Prevented read-only management commands from creating the django_migrations table.

MigrationRecorder now assumes that if the django_migrations table
doesn't exist, then no migrations are applied.

Reverted documentation change from refs #23808.

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