~midonet-drivers/python-networking-midonet/liberty

« back to all changes in this revision

Viewing changes to midonet/neutron/db/migration/alembic_migration/versions/d8a5c672761_add_data_sync.py

  • Committer: Jaume Devesa
  • Date: 2015-08-25 12:33:00 UTC
  • Revision ID: devvesa@gmail.com-20150825123300-x39xyxc5wjsrm7me
Removing tarball data

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2015 Midokura SARL
2
 
#
3
 
# Licensed under the Apache License, Version 2.0 (the "License");
4
 
# you may not use this file except in compliance with the License.
5
 
# You may obtain 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,
11
 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 
# See the License for the specific language governing permissions and
13
 
# limitations under the License.
14
 
 
15
 
"""add data sync
16
 
 
17
 
Revision ID: d8a5c672761
18
 
Revises: 25aeae45d4ad
19
 
Create Date: 2015-03-16 06:04:40.695379
20
 
 
21
 
"""
22
 
 
23
 
# revision identifiers, used by Alembic.
24
 
revision = 'd8a5c672761'
25
 
down_revision = '25aeae45d4ad'
26
 
 
27
 
from alembic import op
28
 
import datetime
29
 
import sqlalchemy as sa
30
 
 
31
 
 
32
 
def upgrade():
33
 
 
34
 
    op.create_table('midonet_data_versions',
35
 
                    sa.Column('id', sa.Integer(), primary_key=True),
36
 
                    sa.Column('sync_started_at', sa.DateTime()),
37
 
                    sa.Column('sync_finished_at', sa.DateTime()),
38
 
                    sa.Column('sync_status', sa.String(length=50)),
39
 
                    sa.Column('sync_tasks_status', sa.String(length=50)),
40
 
                    sa.Column('stale', sa.Boolean(), nullable=False))
41
 
 
42
 
    op.create_table('midonet_data_state',
43
 
                    sa.Column('id', sa.Integer(), primary_key=True),
44
 
                    sa.Column('last_processed_task_id', sa.Integer()),
45
 
                    sa.Column('updated_at', sa.DateTime(),
46
 
                              default=datetime.datetime.utcnow,
47
 
                              nullable=False),
48
 
                    sa.Column('active_version', sa.Integer()),
49
 
                    sa.Column('readonly', sa.Boolean(), nullable=False),
50
 
                    sa.ForeignKeyConstraint(
51
 
                        ['last_processed_task_id'], ['midonet_tasks.id']),
52
 
                    sa.ForeignKeyConstraint(
53
 
                        ['active_version'],
54
 
                        ['midonet_data_versions.id']))
55
 
 
56
 
    op.execute("INSERT INTO midonet_data_state (id, last_processed_task_id, "
57
 
               "updated_at, active_version, readonly) VALUES (1, NULL, '%s', "
58
 
               "NULL, false)" % (datetime.datetime.utcnow()))
 
 
b'\\ No newline at end of file'