# Copyright 2015 OpenStack Foundation
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
#
# Copyright (c) 2015 Wind River Systems, Inc.
#

"""host interface providernet bindings

Revision ID: 10b1502ffd1c
Revises: 3c52bf0d97f3
Create Date: 2015-03-13 00:36:08.201998

"""

# revision identifiers, used by Alembic.
revision = '10b1502ffd1c'
down_revision = '428d71c78e01'

from alembic import op
import sqlalchemy as sa


def upgrade():
    # commands auto generated by Alembic - please adjust!
    op.create_table(
        'hostinterfaces',
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('host_id', sa.String(length=36), nullable=True),
        sa.Column('mtu', sa.Integer(), nullable=False),
        sa.Column('network_type', sa.String(length=255), nullable=True),
        sa.Column('vlans', sa.String(length=255), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['host_id'], ['hosts.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )

    op.create_table(
        'hostinterfaceprovidernetbindings',
        sa.Column('providernet_id', sa.String(length=36), nullable=False),
        sa.Column('interface_id', sa.String(length=36), nullable=False),
        sa.ForeignKeyConstraint(['interface_id'], ['hostinterfaces.id'],
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['providernet_id'], ['providernets.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('providernet_id', 'interface_id')
    )
    # end Alembic commands


def downgrade():
    # commands auto generated by Alembic - please adjust!
    op.drop_table('hostinterfaceprovidernetbindings')
    op.drop_table('hostinterfaces')
    # end Alembic commands
