~rconradharris/nova/server_progress

« back to all changes in this revision

Viewing changes to nova/db/sqlalchemy/migrate_repo/versions/046_add_instances_progress.py

  • Committer: Rick Harris
  • Date: 2011-09-14 15:52:30 UTC
  • Revision ID: rconradharris@gmail.com-20110914155230-9teq3bz168ncxq06
Adding migration for instance progress

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2010 OpenStack LLC.
 
4
#
 
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
 
8
#
 
9
#         http://www.apache.org/licenses/LICENSE-2.0
 
10
#
 
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
 
15
#    under the License.
 
16
 
 
17
from sqlalchemy import *
 
18
from migrate import *
 
19
 
 
20
from nova import log as logging
 
21
 
 
22
meta = MetaData()
 
23
 
 
24
instances = Table('instances', meta,
 
25
    Column("id", Integer(), primary_key=True, nullable=False))
 
26
 
 
27
# Add progress column to instances table
 
28
progress = Column('progress', Integer())
 
29
 
 
30
 
 
31
def upgrade(migrate_engine):
 
32
    meta.bind = migrate_engine
 
33
 
 
34
    try:
 
35
        instances.create_column(progress)
 
36
    except Exception:
 
37
        logging.error(_("progress column not added to instances table"))
 
38
        raise
 
39
 
 
40
 
 
41
def downgrade(migrate_engine):
 
42
    meta.bind = migrate_engine
 
43
    instances.drop_column(progress)