~ubuntu-branches/ubuntu/trusty/cinder/trusty

« back to all changes in this revision

Viewing changes to cinder/db/sqlalchemy/migrate_repo/versions/007_add_ipv6_to_fixed_ips.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-22 09:57:46 UTC
  • Revision ID: package-import@ubuntu.com-20120522095746-9lm71yvzltjybk4b
Tags: upstream-2012.2~f1~20120503.2
ImportĀ upstreamĀ versionĀ 2012.2~f1~20120503.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2011 OpenStack LLC
 
2
# All Rights Reserved.
 
3
#
 
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
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
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
 
14
#    under the License.
 
15
 
 
16
from sqlalchemy import Column, Integer, MetaData, String, Table
 
17
 
 
18
 
 
19
def upgrade(migrate_engine):
 
20
    # Upgrade operations go here. Don't create your own engine;
 
21
    # bind migrate_engine to your metadata
 
22
    meta = MetaData()
 
23
    meta.bind = migrate_engine
 
24
 
 
25
    fixed_ips = Table('fixed_ips', meta, autoload=True)
 
26
 
 
27
    #
 
28
    # New Columns
 
29
    #
 
30
    fixed_ips_addressV6 = Column(
 
31
        "addressV6",
 
32
        String(
 
33
            length=255,
 
34
            convert_unicode=False,
 
35
            assert_unicode=None,
 
36
            unicode_error=None,
 
37
            _warn_on_bytestring=False))
 
38
 
 
39
    fixed_ips_netmaskV6 = Column(
 
40
        "netmaskV6",
 
41
        String(
 
42
            length=3,
 
43
            convert_unicode=False,
 
44
            assert_unicode=None,
 
45
            unicode_error=None,
 
46
            _warn_on_bytestring=False))
 
47
 
 
48
    fixed_ips_gatewayV6 = Column(
 
49
        "gatewayV6",
 
50
        String(
 
51
            length=255,
 
52
            convert_unicode=False,
 
53
            assert_unicode=None,
 
54
            unicode_error=None,
 
55
            _warn_on_bytestring=False))
 
56
    # Add columns to existing tables
 
57
    fixed_ips.create_column(fixed_ips_addressV6)
 
58
    fixed_ips.create_column(fixed_ips_netmaskV6)
 
59
    fixed_ips.create_column(fixed_ips_gatewayV6)
 
60
 
 
61
 
 
62
def downgrade(migrate_engine):
 
63
    meta = MetaData()
 
64
    meta.bind = migrate_engine
 
65
 
 
66
    fixed_ips = Table('fixed_ips', meta, autoload=True)
 
67
 
 
68
    fixed_ips.drop_column('addressV6')
 
69
    fixed_ips.drop_column('netmaskV6')
 
70
    fixed_ips.drop_column('gatewayV6')