1 # Copyright 2016 Red Hat Inc.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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
16 """Add journal maintenance table
18 Revision ID: 703dbf02afde
20 Create Date: 2016-04-12 10:49:31.802663
24 # revision identifiers, used by Alembic.
25 revision = '703dbf02afde'
26 down_revision = '37e242787ae5'
28 from alembic import op
29 from oslo_utils import uuidutils
30 import sqlalchemy as sa
32 from networking_odl.common import constants as odl_const
36 maint_table = op.create_table(
37 'opendaylight_maintenance',
38 sa.Column('id', sa.String(36), primary_key=True),
39 sa.Column('state', sa.Enum(odl_const.PENDING, odl_const.PROCESSING,
42 sa.Column('processing_operation', sa.String(70)),
43 sa.Column('lock_updated', sa.TIMESTAMP, nullable=False,
44 server_default=sa.func.now(),
45 onupdate=sa.func.now())
48 # Insert the only row here that is used to synchronize the lock between
49 # different Neutron processes.
50 op.bulk_insert(maint_table,
51 [{'id': uuidutils.generate_uuid(),
52 'state': odl_const.PENDING}])