@@ -0,0 +1,1469 @@
+# Copyright (c) 2015 Rackspace Inc.%0A#%0A# Author: Tim Simmons %3Ctim.simmons@rackspace.com%3E%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22); you may%0A# not use this file except in compliance with the License. You may obtain%0A# a copy of the License at%0A#%0A#      http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A# License for the specific language governing permissions and limitations%0A# under the License.%0Afrom sqlalchemy import Index, MetaData, Table%0Afrom oslo_log import log as logging%0A%0ALOG = logging.getLogger(__name__)%0A%0Ameta = MetaData()%0A%0A%0Adef index_exists(index):%0A    table = index%5B1%5D._get_table()%0A    cols = sorted(%5Bstr(x).split('.')%5B1%5D for x in index%5B1:%5D%5D)%0A%0A    for idx in table.indexes:%0A        if sorted(idx.columns.keys()) == cols:%0A            return True%0A    return False%0A%0A%0Adef upgrade(migrate_engine):%0A%0A    meta.bind = migrate_engine%0A%0A    records_table = Table('records', meta, autoload=True)%0A%0A    indices = %5B%0A        %5B'update_status_index', records_table.c.status,%0A         records_table.c.domain_id, records_table.c.tenant_id,%0A         records_table.c.created_at, records_table.c.serial%5D%0A    %5D%0A%0A    for ind in indices:%0A        if not index_exists(ind):%0A            index = Index(*ind)%0A            index.create(migrate_engine)%0A

Add an index to speed up update_status