[Fixed]-Django: migrations for tables that are not linked to models

1👍

You can use the usual migrations system.

First, create an empty migration (in whatever app is most appropriate).

python manage.py makemigrations --empty yourappname

Then put in whatever RunSQL operations you need (including the SQL for reverting the changes, if you want).

operations = [
    migrations.RunSQL("CREATE ...",
                      "DROP ..."),
    ...
]

The result can be run right alongside your migrations for Django models.

python manage.py migrate

Leave a comment