~ubuntu-branches/ubuntu/utopic/openstack-trove/utopic-proposed

« back to all changes in this revision

Viewing changes to trove/db/sqlalchemy/migrate_repo/versions/030_add_master_slave.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-08-01 10:03:27 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20140801100327-d53biy1hjecemoyz
Tags: 2014.2~b2-0ubuntu1
* New upstream beta for Juno release:
  - d/p/*: Refreshed.
  - d/control: Add python-neutronclient to (Build-)Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright Tesora, Inc. 2014
 
2
#
 
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
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
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
 
13
#    under the License.
 
14
 
 
15
from sqlalchemy.schema import Column
 
16
from sqlalchemy.schema import MetaData
 
17
from sqlalchemy.schema import ForeignKey
 
18
 
 
19
from trove.db.sqlalchemy.migrate_repo.schema import String
 
20
from trove.db.sqlalchemy.migrate_repo.schema import Table
 
21
 
 
22
COLUMN_NAME = 'slave_of_id'
 
23
 
 
24
 
 
25
def upgrade(migrate_engine):
 
26
    meta = MetaData()
 
27
    meta.bind = migrate_engine
 
28
    instances = Table('instances', meta, autoload=True)
 
29
    instances.create_column(
 
30
        Column(COLUMN_NAME, String(36), ForeignKey('instances.id')),
 
31
        nullable=True)
 
32
 
 
33
 
 
34
def downgrade(migrate_engine):
 
35
    meta = MetaData()
 
36
    meta.bind = migrate_engine
 
37
    instances = Table('instances', meta, autoload=True)
 
38
    instances.drop_column(COLUMN_NAME)