Creating and executing migrations in unit tests

I am working on a PR to django, specifically on a test for which a dummy model is required. I am having a hard time figuring out:

  • how to generate migrations and test migrations automatically.
  • how to have the test migration executed with the test, as right now I am receiving a django.db.utils.OperationalError: no such table: my_table error.

Here’s a link to the PR, if interested in taking a look: Fixed #33206 -- Add redirect type choice to contrib.redirects by niccolomineo · Pull Request #15002 · django/django · GitHub

edit: the PR is being altered due to scope reduction, but the question still haunts me. :slight_smile:

Thank you.