'Take a project_state representing all migrations prior to this one
and a schema_editor for a live database and apply the migration
in a forwards order.
Return the resulting project state for efficient reuse by following
Migrations.'

def apply(self, project_state, schema_editor, collect_sql=False):

    for operation in self.operations:
        if collect_sql:
            schema_editor.collected_sql.append('--')
            if (not operation.reduces_to_sql):
                schema_editor.collected_sql.append('--    MIGRATION    NOW    PERFORMS    OPERATION    THAT    CANNOT    BE    WRITTEN    AS    SQL:')
            schema_editor.collected_sql.append(('--    %s' % operation.describe()))
            schema_editor.collected_sql.append('--')
            if (not operation.reduces_to_sql):
                continue
        old_state = project_state.clone()
        operation.state_forwards(self.app_label, project_state)
        atomic_operation = (operation.atomic or (self.atomic and (operation.atomic is not False)))
        if ((not schema_editor.atomic_migration) and atomic_operation):
            with atomic(schema_editor.connection.alias):
                operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
        else:
            operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
    return project_state
