﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24759	Add or document a way to test data migrations	Tom Linford	Hwayoung Cha	"At Robinhood, we've been using a custom in-house `MigrationTestCase` that we'd like to contribute, but want to check the API of it before contributing it. Here's the definition of the class:

{{{
class MigrationTestCase(TransactionTestCase):
    """"""
    app_label: name of app (ie. ""users"" or ""polls"")
    (start|dest)_migration_name: name of migration in app
        (e.g. ""0001_initial"")
    additional_dependencies: list of tuples of `(app_label, migration_name)`.
        Add any additional migrations here that need to be included in the
        generation of the model states.

    Usage:

    class TestCase(MigrationTestCase):
        app_label = ...
        start_migration_name = ...
        dest_migration_name = ...
        additional_dependencies = ...

        def setUp(self):
            # Create models with regular orm
            super(TestCase, self).setUp()
            # Create models with start orm. Access model with:
            # self.start_models[""<app_label>""][""<model_name>""]
            # Note that model_name must be all lower case, you can just do:
            # <instance>._meta.model_name to get the model_name

        def test(self):
            # Still using start orm
            self.migrate_to_dest()
            # Now, you can access dest models with:
            # self.dest_models[""<app_label>""][""<model_name>""]
    """"""
    app_label = None
    start_migration_name = None
    dest_migration_name = None
    additional_dependencies = []
}}}

Let me know if this API is agreeable and I can make a PR for this feature."	New feature	assigned	Testing framework	1.8	Normal		migrations		Accepted	0	0	0	0	0	0
