1
# Copyright (c) 2011 NTT.
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, Integer
17
from sqlalchemy import MetaData, String, Table
20
def upgrade(migrate_engine):
21
# Upgrade operations go here. Don't create your own engine;
22
# bind migrate_engine to your metadata
24
meta.bind = migrate_engine
27
instances = Table('instances', meta, autoload=True)
29
networks = Table('networks', meta, autoload=True)
30
fixed_ips = Table('fixed_ips', meta, autoload=True)
33
networks.c.ra_server.alter(name='gateway_v6')
34
# Add new column to existing table
35
networks_netmask_v6 = Column(
37
String(length=255, convert_unicode=False, assert_unicode=None,
38
unicode_error=None, _warn_on_bytestring=False))
39
networks.create_column(networks_netmask_v6)
41
# drop existing columns from table
42
fixed_ips.c.addressV6.drop()
43
fixed_ips.c.netmaskV6.drop()
44
fixed_ips.c.gatewayV6.drop()
47
def downgrade(migrate_engine):
49
meta.bind = migrate_engine
52
instances = Table('instances', meta, autoload=True)
54
networks = Table('networks', meta, autoload=True)
55
fixed_ips = Table('fixed_ips', meta, autoload=True)
57
networks.c.gateway_v6.alter(name='ra_server')
58
networks.drop_column('netmask_v6')
60
fixed_ips_addressV6 = Column(
64
convert_unicode=False,
67
_warn_on_bytestring=False))
69
fixed_ips_netmaskV6 = Column(
73
convert_unicode=False,
76
_warn_on_bytestring=False))
78
fixed_ips_gatewayV6 = Column(
82
convert_unicode=False,
85
_warn_on_bytestring=False))
87
for column in (fixed_ips_addressV6,
90
fixed_ips.create_column(column)