'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 detect_soft_applied(self, project_state, migration):

    def should_skip_detecting_model(migration, model):
        "\n                                                No    need    to    detect    tables    for    proxy    models,    unmanaged    models,    or\n                                                models    that    can't    be    migrated    on    the    current    database.\n                                                "
        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)))
    if (migration.initial is None):
        if any(((app == migration.app_label) for (app, name) in migration.dependencies)):
            return (False, project_state)
    elif (migration.initial is False):
        return (False, project_state)
    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
    found_create_model_migration = False
    found_add_field_migration = False
    existing_table_names = self.connection.introspection.table_names(self.connection.cursor())
    for operation in migration.operations:
        if isinstance(operation, migrations.CreateModel):
            model = apps.get_model(migration.app_label, operation.name)
            if model._meta.swapped:
                model = global_apps.get_model(model._meta.swapped)
            if should_skip_detecting_model(migration, model):
                continue
            if (model._meta.db_table not in existing_table_names):
                return (False, project_state)
            found_create_model_migration = True
        elif isinstance(operation, migrations.AddField):
            model = apps.get_model(migration.app_label, operation.model_name)
            if model._meta.swapped:
                model = global_apps.get_model(model._meta.swapped)
            if should_skip_detecting_model(migration, model):
                continue
            table = model._meta.db_table
            field = model._meta.get_field(operation.name)
            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):
                return (False, project_state)
            found_add_field_migration = True
    return ((found_create_model_migration or found_add_field_migration), after_state)
