1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2012 OpenStack LLC.
5
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
# not use this file except in compliance with the License. You may obtain
7
# a copy of the License at
9
# http://www.apache.org/licenses/LICENSE-2.0
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
# License for the specific language governing permissions and limitations
17
from sqlalchemy import Column, DateTime, Text, Boolean
18
from sqlalchemy import MetaData, Integer, String, Table, ForeignKey
20
from cinder.openstack.common import log as logging
22
LOG = logging.getLogger(__name__)
25
def upgrade(migrate_engine):
27
meta.bind = migrate_engine
29
# Just for the ForeignKey and column creation to succeed, these are not the
30
# actual definitions of tables .
32
volumes = Table('volumes', meta,
33
Column('id', Integer(), primary_key=True, nullable=False),
36
snapshots = Table('snapshots', meta,
37
Column('id', Integer(), primary_key=True, nullable=False),
41
volume_glance_metadata = Table('volume_glance_metadata', meta,
42
Column('created_at', DateTime(timezone=False)),
43
Column('updated_at', DateTime(timezone=False)),
44
Column('deleted_at', DateTime(timezone=False)),
45
Column('deleted', Boolean(create_constraint=True, name=None)),
46
Column('id', Integer(), primary_key=True, nullable=False),
47
Column('volume_id', String(length=36), ForeignKey('volumes.id')),
48
Column('snapshot_id', String(length=36),
49
ForeignKey('snapshots.id')),
50
Column('key', String(255)),
51
Column('value', Text),
56
volume_glance_metadata.create()
58
LOG.exception("Exception while creating table "
59
"'volume_glance_metedata'")
60
meta.drop_all(tables=[volume_glance_metadata])
64
def downgrade(migrate_engine):
66
meta.bind = migrate_engine
68
volume_glance_metadata = Table('volume_glance_metadata',
71
volume_glance_metadata.drop()
73
LOG.error(_("volume_glance_metadata table not dropped"))