def execute_migration(schema_editor, operations, project=None):
"""Executes the specified migration operations
using the specified schema editor.
Arguments:
schema_editor:
The schema editor to use to
execute the migrations.
operations:
The migration operations to execute.
project:
The project state to use during the
migrations.
"""
project = project or migrations.state.ProjectState.from_apps(apps)
class Migration(migrations.Migration):
pass
Migration.operations = operations
executor = MigrationExecutor(schema_editor.connection)
executor.apply_migration(
project, Migration('eh', 'postgres_extra'))
评论列表
文章目录