~niedbalski/ubuntu/vivid/neutron/fixes-1447803

« back to all changes in this revision

Viewing changes to neutron/db/migration/alembic_migrations/versions/33c3db036fe4_set_length_of_description_field_metering.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-10-03 18:45:23 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20141003184523-4mt6dy1q3j8n30c9
Tags: 1:2014.2~rc1-0ubuntu1
* New upstream release candidate:
  - d/p/*: Refreshed.
  - d/control: Add python-requests-mock to BD's.
  - d/control: Align versioned requirements with upstream.
* Transition linuxbridge and openvswitch plugin users to modular
  layer 2 plugin (LP: #1323729):
  - d/control: Mark removed plugin packages as transitional, depend
    on neutron-plugin-ml2, mark oldlibs/extra.
  - d/neutron-plugin-{linuxbridge,openvswitch}.install: Drop.
  - d/control: Depend on neutron-plugin-ml2 for linuxbridge
    agent package.
  - d/neutron-plugin-linuxbridge-agent.upstart: Use ml2 plugin
    configuration files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
revision = '33c3db036fe4'
26
26
down_revision = 'b65aa907aec'
27
27
 
28
 
# Change to ['*'] if this migration applies to all plugins
29
 
 
30
 
migration_for_plugins = [
31
 
    'neutron.services.metering.metering_plugin.MeteringPlugin'
32
 
]
33
 
 
34
28
from alembic import op
35
29
import sqlalchemy as sa
36
30
 
37
31
from neutron.db import migration
38
 
 
39
 
 
40
 
def upgrade(active_plugins=None, options=None):
41
 
    if not migration.should_run(active_plugins, migration_for_plugins):
42
 
        return
43
 
 
44
 
    if op.get_bind().engine.dialect.name == 'postgresql':
45
 
        migration.create_table_if_not_exist_psql(
46
 
            'meteringlabels',
47
 
            "(tenant_id VARCHAR(255) NULL, "
48
 
            "id VARCHAR(36) PRIMARY KEY NOT NULL, "
49
 
            "name VARCHAR(255) NULL, "
50
 
            "description VARCHAR(255) NULL)")
 
32
from neutron.db.migration.alembic_migrations import metering_init_ops
 
33
 
 
34
 
 
35
def upgrade():
 
36
    if migration.schema_has_table('meteringlabels'):
 
37
        op.alter_column('meteringlabels', 'description', type_=sa.String(1024),
 
38
                        existing_nullable=True)
51
39
    else:
52
 
        op.execute("CREATE TABLE IF NOT EXISTS meteringlabels( "
53
 
                   "tenant_id VARCHAR(255) NULL, "
54
 
                   "id VARCHAR(36) PRIMARY KEY NOT NULL, "
55
 
                   "name VARCHAR(255) NULL, "
56
 
                   "description VARCHAR(255) NULL)")
57
 
 
58
 
    op.alter_column('meteringlabels', 'description', type_=sa.String(1024),
59
 
                    existing_nullable=True)
60
 
 
61
 
 
62
 
def downgrade(active_plugins=None, options=None):
63
 
    if not migration.should_run(active_plugins, migration_for_plugins):
64
 
        return
65
 
 
 
40
        metering_init_ops.create_meteringlabels()
 
41
 
 
42
 
 
43
def downgrade():
66
44
    pass