¡@

Home 

OpenStack Study: 2447ad0e9585_add_ipv6_mode_props.py

OpenStack Index

**** CubicPower OpenStack Study ****

def upgrade(active_plugins=None, options=None):

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    # Workaround for Alemic bug #89

    # https://bitbucket.org/zzzeek/alembic/issue/89

    context = op.get_context()

    if context.bind.dialect.name == 'postgresql':

        op.execute("CREATE TYPE ipv6_modes AS ENUM ('%s', '%s', '%s')"

                   % ('slaac', 'dhcpv6-stateful', 'dhcpv6-stateless'))

    op.add_column('subnets',

                  sa.Column('ipv6_ra_mode',

                            sa.Enum('slaac',

                                    'dhcpv6-stateful',

                                    'dhcpv6-stateless',

                                    name='ipv6_modes'),

                            nullable=True)

                  )

    op.add_column('subnets',

                  sa.Column('ipv6_address_mode',

                            sa.Enum('slaac',

                                    'dhcpv6-stateful',

                                    'dhcpv6-stateless',

                                    name='ipv6_modes'),

                            nullable=True)

                  )

**** CubicPower OpenStack Study ****

def downgrade(active_plugins=None, options=None):

    if not migration.should_run(active_plugins, migration_for_plugins):

        return

    op.drop_column('subnets', 'ipv6_ra_mode')

    op.drop_column('subnets', 'ipv6_address_mode')

    context = op.get_context()

    if context.bind.dialect.name == 'postgresql':

        op.execute('DROP TYPE ipv6_modes')