Пример #1
0
    def rescan_indexes(self):
        """Rescan the list of indexes from the database.

        This will look up all indexes found in the database, recording each
        one's table. If there are existing indexes being tracked for a table
        containing indexes, they will be removed.
        """
        evolver = EvolutionOperationsMulti(self.db_name).get_evolver()
        connection = evolver.connection
        introspection = connection.introspection
        cursor = connection.cursor()

        for table_name in introspection.get_table_list(cursor):
            if hasattr(table_name, 'name'):
                # Django >= 1.7
                table_name = table_name.name

            if self.has_table(table_name):
                self.clear_indexes(table_name)
            else:
                self.add_table(table_name)

            indexes = evolver.get_indexes_for_table(table_name)

            for index_name, index_info in six.iteritems(indexes):
                self.add_index(table_name=table_name,
                               index_name=index_name,
                               columns=index_info['columns'],
                               unique=index_info['unique'])
Пример #2
0
    def rescan_indexes(self):
        """Rescan the list of indexes from the database.

        This will look up all indexes found in the database, recording each
        one's table. If there are existing indexes being tracked for a table
        containing indexes, they will be removed.
        """
        evolver = EvolutionOperationsMulti(self.db_name).get_evolver()
        connection = evolver.connection
        introspection = connection.introspection
        cursor = connection.cursor()

        for table_name in introspection.get_table_list(cursor):
            if hasattr(table_name, 'name'):
                # Django >= 1.7
                table_name = table_name.name

            if self.has_table(table_name):
                self.clear_indexes(table_name)
            else:
                self.add_table(table_name)

            indexes = evolver.get_indexes_for_table(table_name)

            for index_name, index_info in six.iteritems(indexes):
                self.add_index(table_name=table_name,
                               index_name=index_name,
                               columns=index_info['columns'],
                               unique=index_info['unique'])
Пример #3
0
def rescan_indexes_for_database_sig(database_sig, database):
    evolver = EvolutionOperationsMulti(database).get_evolver()
    connection = evolver.connection
    introspection = connection.introspection
    cursor = connection.cursor()

    for table_name in introspection.get_table_list(cursor):
        table_sig = create_empty_database_table_sig()
        indexes = evolver.get_indexes_for_table(table_name)

        for index_name, index_info in indexes.iteritems():
            table_sig['indexes'][index_name] = index_info

        database_sig[table_name] = table_sig
Пример #4
0
def rescan_indexes_for_database_sig(database_sig, database):
    evolver = EvolutionOperationsMulti(database).get_evolver()
    connection = evolver.connection
    introspection = connection.introspection
    cursor = connection.cursor()

    for table_name in introspection.get_table_list(cursor):
        if hasattr(table_name, 'name'):
            # Django >= 1.7
            table_name = table_name.name

        table_sig = create_empty_database_table_sig()
        indexes = evolver.get_indexes_for_table(table_name)

        for index_name, index_info in indexes.iteritems():
            table_sig['indexes'][index_name] = index_info

        database_sig[table_name] = table_sig