Opened 5 years ago

Closed 4 years ago

Last modified 4 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: master
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 Changed 5 years ago by Shai Berger

Cc: Andrew Godwin added

comment:2 Changed 5 years ago by Tim Graham

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 Changed 5 years ago by Shai Berger

#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 Changed 4 years ago by Andrew Godwin

Owner: changed from nobody to Andrew Godwin
Status: newassigned

comment:5 Changed 4 years ago by Andrew Godwin

comment:6 Changed 4 years ago by Tim Graham <timograham@…>

In 04e69598:

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

comment:7 Changed 4 years ago by Tim Graham <timograham@…>

In b60375d4:

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

comment:8 Changed 4 years ago by Collin Anderson

Cc: cmawebsite@… added

comment:9 Changed 4 years ago by Markus Holtermann

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

comment:10 Changed 4 years ago by Markus Holtermann

Has patch: set
Keywords: 1.9 added

comment:11 Changed 4 years ago by Tim Graham

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 Changed 4 years ago by Tim Graham

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:13 Changed 4 years ago by Markus Holtermann <info@…>

Resolution: fixed
Status: assignedclosed

In a3c01b0:

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

comment:14 Changed 4 years ago by Markus Holtermann <info@…>

In f45ee197:

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

comment:15 in reply to:  11 Changed 4 years ago by Markus Holtermann

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 Changed 4 years ago by Simon Charette <charette.s@…>

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 Changed 4 years ago by Simon Charette <charette.s@…>

In 477274ac:

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

comment:18 Changed 4 years ago by Simon Charette <charette.s@…>

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 Changed 4 years ago by Simon Charette <charette.s@…>

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