1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2012 OpenStack LLC.
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
10
# http://www.apache.org/licenses/LICENSE-2.0
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
18
from sqlalchemy import Index, MetaData, Table
19
from sqlalchemy.exc import IntegrityError
22
def upgrade(migrate_engine):
24
meta.bind = migrate_engine
26
t = Table('networks', meta, autoload=True)
28
# Based on network_get_by_bridge
29
# from: nova/db/sqlalchemy/api.py
30
i = Index('networks_bridge_deleted_idx',
31
t.c.bridge, t.c.deleted)
33
i.create(migrate_engine)
34
except IntegrityError:
37
# Based on network_get_all_by_host
38
# from: nova/db/sqlalchemy/api.py
39
i = Index('networks_host_idx', t.c.host)
41
i.create(migrate_engine)
42
except IntegrityError:
45
# Based on network_query
46
# from: nova/db/sqlalchemy/api.py
47
i = Index('networks_project_id_deleted_idx',
48
t.c.project_id, t.c.deleted)
50
i.create(migrate_engine)
51
except IntegrityError:
54
# Based on network_get_all_by_uuids
55
# from: nova/db/sqlalchemy/api.py
56
i = Index('networks_uuid_project_id_deleted_idx',
57
t.c.uuid, t.c.project_id, t.c.deleted)
59
i.create(migrate_engine)
60
except IntegrityError:
63
# Based on network_create_safe
64
# from: nova/db/sqlalchemy/api.py
65
i = Index('networks_vlan_deleted_idx',
66
t.c.vlan, t.c.deleted)
68
i.create(migrate_engine)
69
except IntegrityError:
72
# Based on network_get_by_cidr
73
# from: nova/db/sqlalchemy/api.py
74
i = Index('networks_cidr_v6_idx', t.c.cidr_v6)
76
i.create(migrate_engine)
77
except IntegrityError:
81
def downgrade(migrate_engine):
83
meta.bind = migrate_engine
85
t = Table('networks', meta, autoload=True)
87
i = Index('networks_bridge_deleted_idx',
88
t.c.bridge, t.c.deleted)
89
i.drop(migrate_engine)
91
i = Index('networks_host_idx', t.c.host)
92
i.drop(migrate_engine)
94
i = Index('networks_project_id_deleted_idx',
95
t.c.project_id, t.c.deleted)
96
i.drop(migrate_engine)
98
i = Index('networks_uuid_project_id_deleted_idx',
99
t.c.uuid, t.c.project_id, t.c.deleted)
100
i.drop(migrate_engine)
102
i = Index('networks_vlan_deleted_idx',
103
t.c.vlan, t.c.deleted)
104
i.drop(migrate_engine)
106
i = Index('networks_cidr_v6_idx', t.c.cidr_v6)
107
i.drop(migrate_engine)