def RenameAppInMigrationsTable(old_app_name, new_app_name):
"""
Check whether an obsolete application name `old_app_name` is present in
Django's `django_migrations` DB table and handle the situation as cleanly
as possible.
If there are migrations for the old app name, perform an UPDATE command to
rename the app in this table so future migration runs will succeed, then
exit with a `ObsoleteAppNameInMigrationsTableException` to indicate that
migrations need to be re-run.
If there are no migrations for the old app name -- e.g. the app has already
been renamed in the table, or the old pre-rename migrations were never run
on the DB -- then no action is performed.
"""
return migrations.RunPython(
_assert_and_rename_app_in_migrations(old_app_name, new_app_name)
)
评论列表
文章目录