~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/126_add_indexes_to_instance_faults.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman, Adam Gandelman, Chuck Short
  • Date: 2012-08-27 15:37:18 UTC
  • mfrom: (1.1.60)
  • Revision ID: package-import@ubuntu.com-20120827153718-lj8er44eqqz1gsrj
Tags: 2012.2~rc1~20120827.15815-0ubuntu1
[ Adam Gandelman ]
* New upstream release.

[ Chuck Short ]
* debian/patches/0001-Update-tools-hacking-for-pep8-1.2-and-
  beyond.patch: Dropped we dont run pep8 tests anymore.
* debian/control: Drop pep8 build depends
* debian/*.upstart.in: Make sure we transition correctly from runlevel
  1 to 2. (LP: #820694)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012 OpenStack LLC.
 
4
# All Rights Reserved.
 
5
#
 
6
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
7
#    not use this file except in compliance with the License. You may obtain
 
8
#    a copy of the License at
 
9
#
 
10
#         http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
#    Unless required by applicable law or agreed to in writing, software
 
13
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
14
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
15
#    License for the specific language governing permissions and limitations
 
16
#    under the License.
 
17
 
 
18
from sqlalchemy import Index, MetaData, Table
 
19
from sqlalchemy.exc import IntegrityError
 
20
 
 
21
 
 
22
def upgrade(migrate_engine):
 
23
    meta = MetaData()
 
24
    meta.bind = migrate_engine
 
25
 
 
26
    # Based on instance_fault_get_by_instance_uuids
 
27
    # from: nova/db/sqlalchemy/api.py
 
28
    t = Table('instance_faults', meta, autoload=True)
 
29
    i = Index('instance_faults_instance_uuid_deleted_created_at_idx',
 
30
              t.c.instance_uuid, t.c.deleted, t.c.created_at)
 
31
    try:
 
32
        i.create(migrate_engine)
 
33
    except IntegrityError:
 
34
        pass
 
35
 
 
36
 
 
37
def downgrade(migrate_engine):
 
38
    meta = MetaData()
 
39
    meta.bind = migrate_engine
 
40
 
 
41
    t = Table('instance_faults', meta, autoload=True)
 
42
    i = Index('instance_faults_instance_uuid_deleted_created_at_idx',
 
43
              t.c.instance_uuid, t.c.deleted, t.c.created_at)
 
44
    i.drop(migrate_engine)