Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#24919 closed New feature (fixed)

Add an option not to run migrations when running tests

Reported by: Kai Richard König Owned by: Andrew Godwin
Component: Migrations Version: dev
Severity: Normal Keywords: 1.9
Cc: Andrew Godwin, cmawebsite@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With large apps it takes too long to run all migrations if you just want to run a single test or testcase. Furthermore keepdb is not an option if you already use an in memory sqlite db.

Change History (19)

comment:1 by Shai Berger, 10 years ago

Cc: Andrew Godwin added

comment:2 by Tim Graham, 10 years ago

Summary: Don't run migrations when running testsAdd an option not to run migrations when running tests
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature
Version: 1.8master

comment:3 by Shai Berger, 10 years ago

#24481 is very closely related (essentially, the same mechanism should be used to generate SQL statements. For #24481, they should be printed; here, executed).

comment:4 by Andrew Godwin, 9 years ago

Owner: changed from nobody to Andrew Godwin
Status: newassigned

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

In 04e69598:

Refs #24919 -- Made test models serializable for migrations.

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

In b60375d4:

Fixed #25129 -- Made model instance defaults work with migrations (refs #24919).

comment:8 by Collin Anderson, 9 years ago

Cc: cmawebsite@… added

comment:9 by Markus Holtermann, 9 years ago

@andrewgodwin what's your thought about https://github.com/django/django/pull/5255

comment:10 by Markus Holtermann, 9 years ago

Has patch: set
Keywords: 1.9 added

comment:11 by Tim Graham, 9 years ago

Patch needs improvement: set

Added some ideas for improvement to the PR.

As I mentioned in IRC, it could also be useful to allow the DATABASES['TEST']['MIGRATE'] = False option that Andrew's first PR suggested to be a shortcut for setting MIGRATION_MODULES = {'a': None, 'b': None', ...} for all apps. This could be done later or in a separate commit though. The main concern I have with this idea is whether or not it makes sense in a multi-db situation.

comment:12 by Tim Graham, 9 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:13 by Markus Holtermann <info@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In a3c01b0:

Fixed #24919 -- Allowed disabling of migrations on a per app basis

comment:14 by Markus Holtermann <info@…>, 9 years ago

In f45ee197:

Refs #24919 -- Raised more helpful error message for disabled migrations

in reply to:  11 comment:15 by Markus Holtermann, 9 years ago

Replying to timgraham:

Added some ideas for improvement to the PR.

As I mentioned in IRC, it could also be useful to allow the DATABASES['TEST']['MIGRATE'] = False option that Andrew's first PR suggested to be a shortcut for setting MIGRATION_MODULES = {'a': None, 'b': None', ...} for all apps. This could be done later or in a separate commit though. The main concern I have with this idea is whether or not it makes sense in a multi-db situation.

I created #25388 to keep track of this proposal if somebody wants to work on it.

comment:16 by Simon Charette <charette.s@…>, 9 years ago

In 4dcaa587:

Fixed #26135 -- Adjusted the migration questioner's handling of disabled apps.

This was causing an issue when calling the migrate command in a test case with
the available_apps attribute pointing to an application with migrations
disabled using the MIGRATION_MODULES setting.

Thanks to Tim Graham for the review.

Refs #24919

comment:17 by Simon Charette <charette.s@…>, 9 years ago

In 477274ac:

Refs #24919 -- Used the documented way of disabling migrations per app.

comment:18 by Simon Charette <charette.s@…>, 9 years ago

In abdbf00:

[1.9.x] Fixed #26135 -- Adjusted the migration questioner's handling of disabled apps.

This was causing an issue when calling the migrate command in a test case with
the available_apps attribute pointing to an application with migrations
disabled using the MIGRATION_MODULES setting.

Thanks to Tim Graham for the review.

Refs #24919

Backport of 4dcaa5871b70859952c6f9c437dfe1b5f10509f2 from master

comment:19 by Simon Charette <charette.s@…>, 9 years ago

In 645fddcd:

[1.9.x] Refs #24919 -- Used the documented way of disabling migrations per app.

Backport of 477274acb46b2f07666e9f84dea2e65ea6b63ad3 from master

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