1
# Copyright 2012 OpenStack LLC.
3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
15
from sqlalchemy import String, Column, MetaData, Table
16
from migrate.changeset import UniqueConstraint
18
from nova.openstack.common import log as logging
20
LOG = logging.getLogger(__name__)
23
def upgrade(migrate_engine):
25
meta.bind = migrate_engine
27
dialect = migrate_engine.url.get_dialect().name
29
aggregates = Table('aggregates', meta, autoload=True)
30
if dialect.startswith('sqlite'):
31
aggregates.c.name.alter(unique=False)
32
elif dialect.startswith('postgres'):
33
ucon = UniqueConstraint('name',
34
name='aggregates_name_key',
39
col2 = aggregates.c.name
40
UniqueConstraint(col2, name='name').drop()
43
def downgrade(migrate_engine):
45
meta.bind = migrate_engine
47
aggregates = Table('aggregates', meta, autoload=True)
48
aggregates.c.name.alter(unique=True)