﻿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
36721	Template for data migrations?	Willem Van Onsem		"When running:

{{{
manage.py makemigrations --empty app_name
}}}

we get a file that looks like:

{{{
# Generated by Django 5.2.4 on 2025-11-10 09:23

from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [
        (""app_name"", ""0123_other_migration""),
    ]

    operations = []
}}}

I find it a bit incovenient that each time, I have to remember how to add a `RunPython` migration: this is something that happens regularly, but probably not regularly enough to just remember it.

Is it an idea to make a template that looks like:

{{{
# Generated by Django 5.2.4 on 2025-11-10 09:23

from django.db import migrations


def forward(apps, schema_editor):
    MyModel = apps.get_model('app_name', 'MyModel')

class Migration(migrations.Migration):

    dependencies = [
        (""app_name"", ""0123_other_migration""),
    ]

    operations = [
        migrations.RunPython(forward)
    ]
}}}

This would increase productivity a bit, but I think it will also help users not to import models directly but use the historic models at the time of the migration (probably something that i not always done neatly). Furthermore the migration will by default fail (since no MyModel exists, and therefore prevents adding an empty migration to the chain)."	New feature	closed	Migrations	5.2	Normal	duplicate			Unreviewed	0	0	0	0	0	0
