bbe0c4612e1adfd8b3f3334217684bee83273886
[fds.git] /
1 # Copyright 2016 Red Hat Inc.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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
13 #    under the License.
14 #
15
16 """Add journal maintenance table
17
18 Revision ID: 703dbf02afde
19 Revises: 37e242787ae5
20 Create Date: 2016-04-12 10:49:31.802663
21
22 """
23
24 # revision identifiers, used by Alembic.
25 revision = '703dbf02afde'
26 down_revision = '37e242787ae5'
27
28 from alembic import op
29 from oslo_utils import uuidutils
30 import sqlalchemy as sa
31
32 from networking_odl.common import constants as odl_const
33
34
35 def upgrade():
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,
40                                    name='state'),
41                   nullable=False),
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())
46     )
47
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}])