1
# Copyright 2011 OpenStack LLC.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
from sqlalchemy import Boolean, Column, DateTime, ForeignKey
17
from sqlalchemy import Integer, MetaData, String
18
from sqlalchemy import Table, Text
20
from nova import log as logging
21
from nova import utils
23
LOG = logging.getLogger(__name__)
26
def upgrade(migrate_engine):
28
meta.bind = migrate_engine
31
instances = Table('instances', meta, autoload=True)
36
instance_info_caches = Table('instance_info_caches', meta,
37
Column('created_at', DateTime(timezone=False),
38
default=utils.utcnow()),
39
Column('updated_at', DateTime(timezone=False),
40
onupdate=utils.utcnow()),
41
Column('deleted_at', DateTime(timezone=False)),
42
Column('deleted', Boolean(create_constraint=True, name=None)),
43
Column('id', Integer(), primary_key=True),
44
Column('network_info', Text()),
45
Column('instance_id', String(36),
46
ForeignKey('instances.uuid'),
49
mysql_engine='InnoDB')
50
# create instance_info_caches table
52
instance_info_caches.create()
54
LOG.error(_("Table |%s| not created!"), repr(instance_info_caches))
58
def downgrade(migrate_engine):
60
meta.bind = migrate_engine
63
instances = Table('instances', meta, autoload=True)
65
instance_info_caches = Table('instance_info_caches', meta, autoload=True)
67
instance_info_caches.drop()
69
LOG.error(_("instance_info_caches tables not dropped"))