class documentation

class MigrationExecutor:

View In Hierarchy

End-to-end migration execution - load migrations and run them up or down to a specified set of targets.
Method __init__ Undocumented
Method ​_create​_project​_state Create a project state including all the applications without migrations and applied migrations if with_applied_migrations=True.
Method ​_migrate​_all​_backwards Take a list of 2-tuples of the form (migration instance, True) and unapply them in reverse order they occur in the full_plan.
Method ​_migrate​_all​_forwards Take a list of 2-tuples of the form (migration instance, False) and apply them in the order they occur in the full_plan.
Method apply​_migration Run a migration forwards.
Method check​_replacements Mark replacement migrations applied if their replaced set all are.
Method detect​_soft​_applied Test whether a migration has been implicitly applied - that the tables or columns it would create exist. This is intended only for use on initial migrations (as it only looks for CreateModel and AddField).
Method migrate Migrate the database up to the given targets.
Method migration​_plan Given a set of targets, return a list of (Migration instance, backwards?).
Method record​_migration Undocumented
Method unapply​_migration Run a migration backwards.
Instance Variable connection Undocumented
Instance Variable loader Undocumented
Instance Variable progress​_callback Undocumented
Instance Variable recorder Undocumented
def __init__(self, connection, progress_callback=None):

Undocumented

def _create_project_state(self, with_applied_migrations=False):
Create a project state including all the applications without migrations and applied migrations if with_applied_migrations=True.
def _migrate_all_backwards(self, plan, full_plan, fake):

Take a list of 2-tuples of the form (migration instance, True) and unapply them in reverse order they occur in the full_plan.

Since unapplying a migration requires the project state prior to that migration, Django will compute the migration states before each of them in a first run over the plan and then unapply them in a second run over the plan.

def _migrate_all_forwards(self, state, plan, full_plan, fake, fake_initial):
Take a list of 2-tuples of the form (migration instance, False) and apply them in the order they occur in the full_plan.
def apply_migration(self, state, migration, fake=False, fake_initial=False):
Run a migration forwards.
def check_replacements(self):

Mark replacement migrations applied if their replaced set all are.

Do this unconditionally on every migrate, rather than just when migrations are applied or unapplied, to correctly handle the case when a new squash migration is pushed to a deployment that already had all its replaced migrations applied. In this case no new migration will be applied, but the applied state of the squashed migration must be maintained.

def detect_soft_applied(self, project_state, migration):
Test whether a migration has been implicitly applied - that the tables or columns it would create exist. This is intended only for use on initial migrations (as it only looks for CreateModel and AddField).
def migrate(self, targets, plan=None, state=None, fake=False, fake_initial=False):

Migrate the database up to the given targets.

Django first needs to create all project states before a migration is (un)applied and in a second step run all the database operations.

def migration_plan(self, targets, clean_start=False):
Given a set of targets, return a list of (Migration instance, backwards?).
def record_migration(self, migration):

Undocumented

def unapply_migration(self, state, migration, fake=False):
Run a migration backwards.
connection =

Undocumented

loader =

Undocumented

progress_callback =

Undocumented

recorder =

Undocumented