def sync(alias, only_model=None): engine = get_engine_from_db_alias(alias) if engine != 'django_cassandra_engine': raise CommandError('Database {} is not cassandra!'.format(alias)) connection = connections[alias] connection.connect() keyspace = connection.settings_dict['NAME'] _logger.info('Creating indexes in {} [CONNECTION {}] ..'.format( keyspace, alias)) connection.connection.cluster.refresh_schema_metadata() connection.connection.cluster.schema_metadata_enabled = True indexes_by_model = UnifiedIndex().get_indexes() for app_name, app_models \ in connection.introspection.cql_models.items(): for model in app_models: # If the app model is registered as a SearchIndex if model in indexes_by_model: model_name = "{0}.{1}".format(model.__module__, model.__name__) if not only_model or model_name == only_model: _logger.info("Creating index %s.%s".format( app_name, model.__name__)) _logger.info( "Index class associated to te model {0}.{1}".format( app_name, indexes_by_model.get(model).__class__.__name__)) create_index(model, indexes_by_model.get(model))