2014-07-26 00:35:25 +08:00
|
|
|
from django.apps.registry import apps as global_apps
|
2016-01-25 08:23:38 +08:00
|
|
|
from django.db import migrations, router
|
2015-01-28 20:35:27 +08:00
|
|
|
|
2015-08-27 07:49:35 +08:00
|
|
|
from .exceptions import InvalidMigrationPlan
|
2013-05-31 01:08:58 +08:00
|
|
|
from .loader import MigrationLoader
|
|
|
|
from .recorder import MigrationRecorder
|
2015-01-12 03:13:31 +08:00
|
|
|
from .state import ProjectState
|
2013-05-31 01:08:58 +08:00
|
|
|
|
|
|
|
|
2017-01-19 15:39:46 +08:00
|
|
|
class MigrationExecutor:
|
2013-05-31 01:08:58 +08:00
|
|
|
"""
|
2017-01-25 07:04:12 +08:00
|
|
|
End-to-end migration execution - load migrations and run them up or down
|
|
|
|
to a specified set of targets.
|
2013-05-31 01:08:58 +08:00
|
|
|
"""
|
|
|
|
|
2013-06-08 01:47:17 +08:00
|
|
|
def __init__(self, connection, progress_callback=None):
|
2013-05-31 01:08:58 +08:00
|
|
|
self.connection = connection
|
|
|
|
self.loader = MigrationLoader(self.connection)
|
|
|
|
self.recorder = MigrationRecorder(self.connection)
|
2013-06-08 01:47:17 +08:00
|
|
|
self.progress_callback = progress_callback
|
2013-05-31 01:08:58 +08:00
|
|
|
|
2015-01-12 03:13:31 +08:00
|
|
|
def migration_plan(self, targets, clean_start=False):
|
2013-05-31 01:08:58 +08:00
|
|
|
"""
|
2017-01-25 07:04:12 +08:00
|
|
|
Given a set of targets, return a list of (Migration instance, backwards?).
|
2013-05-31 01:08:58 +08:00
|
|
|
"""
|
|
|
|
plan = []
|
2015-01-12 03:13:31 +08:00
|
|
|
if clean_start:
|
|
|
|
applied = set()
|
|
|
|
else:
|
|
|
|
applied = set(self.loader.applied_migrations)
|
2013-05-31 01:08:58 +08:00
|
|
|
for target in targets:
|
2013-12-28 16:53:02 +08:00
|
|
|
# If the target is (app_label, None), that means unmigrate everything
|
2013-07-23 02:43:58 +08:00
|
|
|
if target[1] is None:
|
|
|
|
for root in self.loader.graph.root_nodes():
|
|
|
|
if root[0] == target[0]:
|
|
|
|
for migration in self.loader.graph.backwards_plan(root):
|
|
|
|
if migration in applied:
|
|
|
|
plan.append((self.loader.graph.nodes[migration], True))
|
|
|
|
applied.remove(migration)
|
2013-05-31 01:08:58 +08:00
|
|
|
# If the migration is already applied, do backwards mode,
|
|
|
|
# otherwise do forwards mode.
|
2013-07-23 02:43:58 +08:00
|
|
|
elif target in applied:
|
2014-11-18 01:13:47 +08:00
|
|
|
# Don't migrate backwards all the way to the target node (that
|
|
|
|
# may roll back dependencies in other apps that don't need to
|
|
|
|
# be rolled back); instead roll back through target's immediate
|
|
|
|
# child(ren) in the same app, and no further.
|
|
|
|
next_in_app = sorted(
|
|
|
|
n for n in
|
2015-02-20 12:43:45 +08:00
|
|
|
self.loader.graph.node_map[target].children
|
2014-11-18 01:13:47 +08:00
|
|
|
if n[0] == target[0]
|
|
|
|
)
|
|
|
|
for node in next_in_app:
|
|
|
|
for migration in self.loader.graph.backwards_plan(node):
|
2013-08-11 22:28:51 +08:00
|
|
|
if migration in applied:
|
|
|
|
plan.append((self.loader.graph.nodes[migration], True))
|
|
|
|
applied.remove(migration)
|
2013-05-31 01:08:58 +08:00
|
|
|
else:
|
|
|
|
for migration in self.loader.graph.forwards_plan(target):
|
|
|
|
if migration not in applied:
|
|
|
|
plan.append((self.loader.graph.nodes[migration], False))
|
|
|
|
applied.add(migration)
|
|
|
|
return plan
|
|
|
|
|
2016-08-21 06:05:04 +08:00
|
|
|
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.
|
|
|
|
"""
|
|
|
|
state = ProjectState(real_apps=list(self.loader.unmigrated_apps))
|
|
|
|
if with_applied_migrations:
|
|
|
|
# Create the forwards plan Django would follow on an empty database
|
|
|
|
full_plan = self.migration_plan(self.loader.graph.leaf_nodes(), clean_start=True)
|
|
|
|
applied_migrations = {
|
|
|
|
self.loader.graph.nodes[key] for key in self.loader.applied_migrations
|
|
|
|
if key in self.loader.graph.nodes
|
|
|
|
}
|
|
|
|
for migration, _ in full_plan:
|
|
|
|
if migration in applied_migrations:
|
|
|
|
migration.mutate_state(state, preserve=False)
|
|
|
|
return state
|
2016-05-13 23:58:54 +08:00
|
|
|
|
2016-08-21 06:05:04 +08:00
|
|
|
def migrate(self, targets, plan=None, state=None, fake=False, fake_initial=False):
|
2013-05-31 01:08:58 +08:00
|
|
|
"""
|
2017-01-25 07:04:12 +08:00
|
|
|
Migrate the database up to the given targets.
|
2015-01-12 03:13:31 +08:00
|
|
|
|
|
|
|
Django first needs to create all project states before a migration is
|
|
|
|
(un)applied and in a second step run all the database operations.
|
2013-05-31 01:08:58 +08:00
|
|
|
"""
|
2016-11-05 16:16:23 +08:00
|
|
|
# The django_migrations table must be present to record applied
|
|
|
|
# migrations.
|
|
|
|
self.recorder.ensure_schema()
|
|
|
|
|
2013-06-08 01:47:17 +08:00
|
|
|
if plan is None:
|
|
|
|
plan = self.migration_plan(targets)
|
2015-01-12 03:13:31 +08:00
|
|
|
# Create the forwards plan Django would follow on an empty database
|
|
|
|
full_plan = self.migration_plan(self.loader.graph.leaf_nodes(), clean_start=True)
|
2015-08-27 07:49:35 +08:00
|
|
|
|
|
|
|
all_forwards = all(not backwards for mig, backwards in plan)
|
|
|
|
all_backwards = all(backwards for mig, backwards in plan)
|
|
|
|
|
|
|
|
if not plan:
|
2016-08-21 06:05:04 +08:00
|
|
|
if state is None:
|
|
|
|
# The resulting state should include applied migrations.
|
|
|
|
state = self._create_project_state(with_applied_migrations=True)
|
2015-08-27 07:49:35 +08:00
|
|
|
elif all_forwards == all_backwards:
|
|
|
|
# This should only happen if there's a mixed plan
|
|
|
|
raise InvalidMigrationPlan(
|
|
|
|
"Migration plans with both forwards and backwards migrations "
|
|
|
|
"are not supported. Please split your migration process into "
|
|
|
|
"separate plans of only forwards OR backwards migrations.",
|
|
|
|
plan
|
|
|
|
)
|
|
|
|
elif all_forwards:
|
2016-08-21 06:05:04 +08:00
|
|
|
if state is None:
|
|
|
|
# The resulting state should still include applied migrations.
|
|
|
|
state = self._create_project_state(with_applied_migrations=True)
|
|
|
|
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
|
2015-08-27 07:49:35 +08:00
|
|
|
else:
|
|
|
|
# No need to check for `elif all_backwards` here, as that condition
|
|
|
|
# would always evaluate to true.
|
2016-05-13 23:58:54 +08:00
|
|
|
state = self._migrate_all_backwards(plan, full_plan, fake=fake)
|
2015-08-27 07:49:35 +08:00
|
|
|
|
|
|
|
self.check_replacements()
|
|
|
|
|
2016-05-13 23:58:54 +08:00
|
|
|
return state
|
|
|
|
|
2016-08-21 06:05:04 +08:00
|
|
|
def _migrate_all_forwards(self, state, plan, full_plan, fake, fake_initial):
|
2015-08-27 07:49:35 +08:00
|
|
|
"""
|
|
|
|
Take a list of 2-tuples of the form (migration instance, False) and
|
|
|
|
apply them in the order they occur in the full_plan.
|
|
|
|
"""
|
|
|
|
migrations_to_run = {m[0] for m in plan}
|
|
|
|
for migration, _ in full_plan:
|
2016-08-21 06:05:04 +08:00
|
|
|
if not migrations_to_run:
|
2016-05-23 08:35:10 +08:00
|
|
|
# We remove every migration that we applied from these sets so
|
2015-08-27 07:49:35 +08:00
|
|
|
# that we can bail out once the last migration has been applied
|
|
|
|
# and don't always run until the very end of the migration
|
|
|
|
# process.
|
|
|
|
break
|
|
|
|
if migration in migrations_to_run:
|
|
|
|
if 'apps' not in state.__dict__:
|
|
|
|
if self.progress_callback:
|
|
|
|
self.progress_callback("render_start")
|
|
|
|
state.apps # Render all -- performance critical
|
|
|
|
if self.progress_callback:
|
|
|
|
self.progress_callback("render_success")
|
|
|
|
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
|
|
|
|
migrations_to_run.remove(migration)
|
|
|
|
|
2016-05-13 23:58:54 +08:00
|
|
|
return state
|
|
|
|
|
2015-08-27 07:49:35 +08:00
|
|
|
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.
|
|
|
|
"""
|
|
|
|
migrations_to_run = {m[0] for m in plan}
|
|
|
|
# Holds all migration states prior to the migrations being unapplied
|
2015-01-12 03:13:31 +08:00
|
|
|
states = {}
|
2016-05-13 23:58:54 +08:00
|
|
|
state = self._create_project_state()
|
|
|
|
applied_migrations = {
|
|
|
|
self.loader.graph.nodes[key] for key in self.loader.applied_migrations
|
|
|
|
if key in self.loader.graph.nodes
|
|
|
|
}
|
2015-01-12 04:07:45 +08:00
|
|
|
if self.progress_callback:
|
|
|
|
self.progress_callback("render_start")
|
2015-01-12 03:13:31 +08:00
|
|
|
for migration, _ in full_plan:
|
2015-04-01 05:35:48 +08:00
|
|
|
if not migrations_to_run:
|
2015-08-27 07:49:35 +08:00
|
|
|
# We remove every migration that we applied from this set so
|
|
|
|
# that we can bail out once the last migration has been applied
|
|
|
|
# and don't always run until the very end of the migration
|
|
|
|
# process.
|
2015-04-01 05:35:48 +08:00
|
|
|
break
|
2015-08-27 07:49:35 +08:00
|
|
|
if migration in migrations_to_run:
|
2015-04-01 05:35:41 +08:00
|
|
|
if 'apps' not in state.__dict__:
|
2015-08-27 07:49:35 +08:00
|
|
|
state.apps # Render all -- performance critical
|
|
|
|
# The state before this migration
|
|
|
|
states[migration] = state
|
|
|
|
# The old state keeps as-is, we continue with the new state
|
|
|
|
state = migration.mutate_state(state, preserve=True)
|
2015-04-01 05:35:48 +08:00
|
|
|
migrations_to_run.remove(migration)
|
2016-05-13 23:58:54 +08:00
|
|
|
elif migration in applied_migrations:
|
|
|
|
# Only mutate the state if the migration is actually applied
|
|
|
|
# to make sure the resulting state doesn't include changes
|
|
|
|
# from unrelated migrations.
|
2015-08-27 07:49:35 +08:00
|
|
|
migration.mutate_state(state, preserve=False)
|
2015-04-01 05:35:41 +08:00
|
|
|
if self.progress_callback:
|
|
|
|
self.progress_callback("render_success")
|
2015-08-27 07:49:35 +08:00
|
|
|
|
|
|
|
for migration, _ in plan:
|
|
|
|
self.unapply_migration(states[migration], migration, fake=fake)
|
2016-05-13 23:58:54 +08:00
|
|
|
applied_migrations.remove(migration)
|
|
|
|
|
|
|
|
# Generate the post migration state by starting from the state before
|
|
|
|
# the last migration is unapplied and mutating it to include all the
|
|
|
|
# remaining applied migrations.
|
|
|
|
last_unapplied_migration = plan[-1][0]
|
|
|
|
state = states[last_unapplied_migration]
|
|
|
|
for index, (migration, _) in enumerate(full_plan):
|
|
|
|
if migration == last_unapplied_migration:
|
|
|
|
for migration, _ in full_plan[index:]:
|
|
|
|
if migration in applied_migrations:
|
|
|
|
migration.mutate_state(state, preserve=False)
|
|
|
|
break
|
|
|
|
|
|
|
|
return state
|
2013-05-31 01:08:58 +08:00
|
|
|
|
2013-09-07 04:27:51 +08:00
|
|
|
def collect_sql(self, plan):
|
|
|
|
"""
|
2017-01-25 07:04:12 +08:00
|
|
|
Take a migration plan and return a list of collected SQL statements
|
|
|
|
that represent the best-efforts version of that plan.
|
2013-09-07 04:27:51 +08:00
|
|
|
"""
|
|
|
|
statements = []
|
2014-10-27 01:30:58 +08:00
|
|
|
state = None
|
2013-09-07 04:27:51 +08:00
|
|
|
for migration, backwards in plan:
|
2016-01-31 04:46:28 +08:00
|
|
|
with self.connection.schema_editor(collect_sql=True, atomic=migration.atomic) as schema_editor:
|
2014-10-27 01:30:58 +08:00
|
|
|
if state is None:
|
|
|
|
state = self.loader.project_state((migration.app_label, migration.name), at_end=False)
|
2013-09-07 04:27:51 +08:00
|
|
|
if not backwards:
|
2014-10-27 01:30:58 +08:00
|
|
|
state = migration.apply(state, schema_editor, collect_sql=True)
|
2013-09-07 04:27:51 +08:00
|
|
|
else:
|
2014-10-27 01:30:58 +08:00
|
|
|
state = migration.unapply(state, schema_editor, collect_sql=True)
|
2013-11-28 00:29:37 +08:00
|
|
|
statements.extend(schema_editor.collected_sql)
|
2013-09-07 04:27:51 +08:00
|
|
|
return statements
|
|
|
|
|
2015-02-12 19:48:28 +08:00
|
|
|
def apply_migration(self, state, migration, fake=False, fake_initial=False):
|
2017-01-25 07:04:12 +08:00
|
|
|
"""Run a migration forwards."""
|
2013-06-08 01:47:17 +08:00
|
|
|
if self.progress_callback:
|
2013-10-30 23:17:28 +08:00
|
|
|
self.progress_callback("apply_start", migration, fake)
|
2013-07-26 23:47:00 +08:00
|
|
|
if not fake:
|
2015-02-12 19:48:28 +08:00
|
|
|
if fake_initial:
|
|
|
|
# Test to see if this is an already-applied initial migration
|
|
|
|
applied, state = self.detect_soft_applied(state, migration)
|
|
|
|
if applied:
|
|
|
|
fake = True
|
|
|
|
if not fake:
|
2013-10-30 23:17:28 +08:00
|
|
|
# Alright, do it normally
|
2016-01-31 04:46:28 +08:00
|
|
|
with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
|
2014-11-06 03:53:39 +08:00
|
|
|
state = migration.apply(state, schema_editor)
|
2013-10-24 05:56:54 +08:00
|
|
|
# For replacement migrations, record individual statuses
|
|
|
|
if migration.replaces:
|
|
|
|
for app_label, name in migration.replaces:
|
|
|
|
self.recorder.record_applied(app_label, name)
|
|
|
|
else:
|
|
|
|
self.recorder.record_applied(migration.app_label, migration.name)
|
2013-10-30 23:17:28 +08:00
|
|
|
# Report progress
|
2013-06-08 01:47:17 +08:00
|
|
|
if self.progress_callback:
|
2013-10-30 23:17:28 +08:00
|
|
|
self.progress_callback("apply_success", migration, fake)
|
2014-10-27 01:30:58 +08:00
|
|
|
return state
|
2013-05-31 01:08:58 +08:00
|
|
|
|
2014-10-27 01:30:58 +08:00
|
|
|
def unapply_migration(self, state, migration, fake=False):
|
2017-01-25 07:04:12 +08:00
|
|
|
"""Run a migration backwards."""
|
2013-06-08 01:47:17 +08:00
|
|
|
if self.progress_callback:
|
2013-10-30 23:17:28 +08:00
|
|
|
self.progress_callback("unapply_start", migration, fake)
|
2013-07-26 23:47:00 +08:00
|
|
|
if not fake:
|
2016-01-31 04:46:28 +08:00
|
|
|
with self.connection.schema_editor(atomic=migration.atomic) as schema_editor:
|
2014-11-06 03:53:39 +08:00
|
|
|
state = migration.unapply(state, schema_editor)
|
2013-10-24 05:56:54 +08:00
|
|
|
# For replacement migrations, record individual statuses
|
|
|
|
if migration.replaces:
|
|
|
|
for app_label, name in migration.replaces:
|
|
|
|
self.recorder.record_unapplied(app_label, name)
|
|
|
|
else:
|
|
|
|
self.recorder.record_unapplied(migration.app_label, migration.name)
|
|
|
|
# Report progress
|
2013-06-08 01:47:17 +08:00
|
|
|
if self.progress_callback:
|
2013-10-30 23:17:28 +08:00
|
|
|
self.progress_callback("unapply_success", migration, fake)
|
2014-10-27 01:30:58 +08:00
|
|
|
return state
|
2013-10-30 23:17:28 +08:00
|
|
|
|
2015-06-03 04:23:07 +08:00
|
|
|
def check_replacements(self):
|
|
|
|
"""
|
|
|
|
Mark replacement migrations applied if their replaced set all are.
|
2015-06-04 03:46:01 +08:00
|
|
|
|
2017-01-25 07:04:12 +08:00
|
|
|
Do this unconditionally on every migrate, rather than just when
|
|
|
|
migrations are applied or unapplied, to correctly handle the case
|
2015-06-04 03:46:01 +08:00
|
|
|
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
|
2017-01-25 07:04:12 +08:00
|
|
|
be applied, but the applied state of the squashed migration must be
|
|
|
|
maintained.
|
2015-06-03 04:23:07 +08:00
|
|
|
"""
|
|
|
|
applied = self.recorder.applied_migrations()
|
|
|
|
for key, migration in self.loader.replacements.items():
|
|
|
|
all_applied = all(m in applied for m in migration.replaces)
|
|
|
|
if all_applied and key not in applied:
|
|
|
|
self.recorder.record_applied(*key)
|
|
|
|
|
2014-10-27 01:30:58 +08:00
|
|
|
def detect_soft_applied(self, project_state, migration):
|
2013-10-30 23:17:28 +08:00
|
|
|
"""
|
2017-01-25 07:04:12 +08:00
|
|
|
Test whether a migration has been implicitly applied - that the
|
2015-04-01 04:30:39 +08:00
|
|
|
tables or columns it would create exist. This is intended only for use
|
|
|
|
on initial migrations (as it only looks for CreateModel and AddField).
|
2013-10-30 23:17:28 +08:00
|
|
|
"""
|
2016-01-25 08:23:38 +08:00
|
|
|
def should_skip_detecting_model(migration, model):
|
|
|
|
"""
|
|
|
|
No need to detect tables for proxy models, unmanaged models, or
|
|
|
|
models that can't be migrated on the current database.
|
|
|
|
"""
|
|
|
|
return (
|
|
|
|
model._meta.proxy or not model._meta.managed or not
|
|
|
|
router.allow_migrate(
|
|
|
|
self.connection.alias, migration.app_label,
|
|
|
|
model_name=model._meta.model_name,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2015-04-01 04:30:39 +08:00
|
|
|
if migration.initial is None:
|
|
|
|
# Bail if the migration isn't the first one in its app
|
|
|
|
if any(app == migration.app_label for app, name in migration.dependencies):
|
|
|
|
return False, project_state
|
|
|
|
elif migration.initial is False:
|
|
|
|
# Bail if it's NOT an initial migration
|
2014-11-06 03:53:39 +08:00
|
|
|
return False, project_state
|
2015-04-01 04:30:39 +08:00
|
|
|
|
2014-11-06 03:53:39 +08:00
|
|
|
if project_state is None:
|
|
|
|
after_state = self.loader.project_state((migration.app_label, migration.name), at_end=True)
|
|
|
|
else:
|
|
|
|
after_state = migration.mutate_state(project_state)
|
|
|
|
apps = after_state.apps
|
2015-04-01 04:30:39 +08:00
|
|
|
found_create_model_migration = False
|
|
|
|
found_add_field_migration = False
|
2015-12-19 21:53:53 +08:00
|
|
|
existing_table_names = self.connection.introspection.table_names(self.connection.cursor())
|
2015-04-01 04:30:39 +08:00
|
|
|
# Make sure all create model and add field operations are done
|
2013-10-30 23:17:28 +08:00
|
|
|
for operation in migration.operations:
|
|
|
|
if isinstance(operation, migrations.CreateModel):
|
2013-12-24 19:25:17 +08:00
|
|
|
model = apps.get_model(migration.app_label, operation.name)
|
2014-07-26 00:35:25 +08:00
|
|
|
if model._meta.swapped:
|
|
|
|
# We have to fetch the model to test with from the
|
|
|
|
# main app cache, as it's not a direct dependency.
|
|
|
|
model = global_apps.get_model(model._meta.swapped)
|
2016-01-25 08:23:38 +08:00
|
|
|
if should_skip_detecting_model(migration, model):
|
2015-04-01 04:30:39 +08:00
|
|
|
continue
|
2015-12-19 21:53:53 +08:00
|
|
|
if model._meta.db_table not in existing_table_names:
|
2014-11-06 03:53:39 +08:00
|
|
|
return False, project_state
|
2015-04-01 04:30:39 +08:00
|
|
|
found_create_model_migration = True
|
|
|
|
elif isinstance(operation, migrations.AddField):
|
|
|
|
model = apps.get_model(migration.app_label, operation.model_name)
|
|
|
|
if model._meta.swapped:
|
|
|
|
# We have to fetch the model to test with from the
|
|
|
|
# main app cache, as it's not a direct dependency.
|
|
|
|
model = global_apps.get_model(model._meta.swapped)
|
2016-01-25 08:23:38 +08:00
|
|
|
if should_skip_detecting_model(migration, model):
|
2015-04-01 04:30:39 +08:00
|
|
|
continue
|
|
|
|
|
|
|
|
table = model._meta.db_table
|
2015-12-19 21:53:53 +08:00
|
|
|
field = model._meta.get_field(operation.name)
|
|
|
|
|
|
|
|
# Handle implicit many-to-many tables created by AddField.
|
|
|
|
if field.many_to_many:
|
|
|
|
if field.remote_field.through._meta.db_table not in existing_table_names:
|
|
|
|
return False, project_state
|
|
|
|
else:
|
|
|
|
found_add_field_migration = True
|
|
|
|
continue
|
|
|
|
|
|
|
|
column_names = [
|
|
|
|
column.name for column in
|
|
|
|
self.connection.introspection.get_table_description(self.connection.cursor(), table)
|
|
|
|
]
|
|
|
|
if field.column not in column_names:
|
2015-04-01 04:30:39 +08:00
|
|
|
return False, project_state
|
|
|
|
found_add_field_migration = True
|
|
|
|
# If we get this far and we found at least one CreateModel or AddField migration,
|
2014-06-23 09:29:27 +08:00
|
|
|
# the migration is considered implicitly applied.
|
2015-04-01 04:30:39 +08:00
|
|
|
return (found_create_model_migration or found_add_field_migration), after_state
|