1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright (c) 2011 Zadara Storage Inc.
4
# Copyright (c) 2011 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 Column, DateTime, Integer, MetaData, String, Table
19
from sqlalchemy import Text, Boolean, ForeignKey
21
from nova import log as logging
25
# Just for the ForeignKey and column creation to succeed, these are not the
26
# actual definitions of tables .
29
volumes = Table('volumes', meta,
30
Column('id', Integer(), primary_key=True, nullable=False),
33
volume_type_id = Column('volume_type_id', Integer(), nullable=True)
39
volume_types = Table('volume_types', meta,
40
Column('created_at', DateTime(timezone=False)),
41
Column('updated_at', DateTime(timezone=False)),
42
Column('deleted_at', DateTime(timezone=False)),
43
Column('deleted', Boolean(create_constraint=True, name=None)),
44
Column('id', Integer(), primary_key=True, nullable=False),
46
String(length=255, convert_unicode=False, assert_unicode=None,
47
unicode_error=None, _warn_on_bytestring=False),
50
volume_type_extra_specs_table = Table('volume_type_extra_specs', meta,
51
Column('created_at', DateTime(timezone=False)),
52
Column('updated_at', DateTime(timezone=False)),
53
Column('deleted_at', DateTime(timezone=False)),
54
Column('deleted', Boolean(create_constraint=True, name=None)),
55
Column('id', Integer(), primary_key=True, nullable=False),
56
Column('volume_type_id',
58
ForeignKey('volume_types.id'),
61
String(length=255, convert_unicode=False, assert_unicode=None,
62
unicode_error=None, _warn_on_bytestring=False)),
64
String(length=255, convert_unicode=False, assert_unicode=None,
65
unicode_error=None, _warn_on_bytestring=False)))
68
volume_metadata_table = Table('volume_metadata', meta,
69
Column('created_at', DateTime(timezone=False)),
70
Column('updated_at', DateTime(timezone=False)),
71
Column('deleted_at', DateTime(timezone=False)),
72
Column('deleted', Boolean(create_constraint=True, name=None)),
73
Column('id', Integer(), primary_key=True, nullable=False),
76
ForeignKey('volumes.id'),
79
String(length=255, convert_unicode=False, assert_unicode=None,
80
unicode_error=None, _warn_on_bytestring=False)),
82
String(length=255, convert_unicode=False, assert_unicode=None,
83
unicode_error=None, _warn_on_bytestring=False)))
86
new_tables = (volume_types,
87
volume_type_extra_specs_table,
88
volume_metadata_table)
95
def upgrade(migrate_engine):
96
meta.bind = migrate_engine
98
for table in new_tables:
102
logging.info(repr(table))
103
logging.exception('Exception while creating table')
106
volumes.create_column(volume_type_id)
109
def downgrade(migrate_engine):
110
meta.bind = migrate_engine
112
volumes.drop_column(volume_type_id)
114
for table in new_tables: