"""empty message

Revision ID: 38893ebb1c0
Revises: 4e4de9b0361
Create Date: 2015-07-16 22:03:46.184063

"""

# revision identifiers, used by Alembic.
revision = '38893ebb1c0'
down_revision = '4e4de9b0361'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('manager',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('model_name', sa.String(length=31), nullable=False),
    sa.Column('owner_id', sa.Integer(), nullable=False),
    sa.Column('paginate_by', sa.Integer(), nullable=True),
    sa.Column('_fields', sa.Text(), nullable=True),
    sa.Column('_create_fields', sa.Text(), nullable=True),
    sa.Column('_update_fields', sa.Text(), nullable=True),
    sa.Column('_list_fields', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('relationship_model',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('embedded', sa.Integer(), nullable=True),
    sa.Column('is_list', sa.Boolean(), nullable=True),
    sa.Column('name', sa.String(length=63), nullable=False),
    sa.Column('no_pks', sa.Boolean(), nullable=True),
    sa.Column('_query_args', sa.Text(), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=False),
    sa.Column('_property_map', sa.Text(), nullable=True),
    sa.Column('relation', sa.String(), nullable=False),
    sa.Column('required', sa.Integer(), nullable=True),
    sa.Column('resource_id', sa.Integer(), nullable=True),
    sa.Column('templated', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['resource_id'], ['resource.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('relationship')
    op.add_column('resource', sa.Column('_pks', sa.Text(), nullable=True))
    op.add_column('resource', sa.Column('manager_id', sa.Integer(), nullable=True))
    op.add_column('resource', sa.Column('owner_id', sa.Integer(), nullable=False))
    op.create_foreign_key(None, 'resource', 'manager', ['manager_id'], ['id'])
    op.create_foreign_key(None, 'resource', 'user', ['owner_id'], ['id'])
    op.drop_column('resource', 'model_name')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('resource', sa.Column('model_name', sa.VARCHAR(length=31), nullable=False))
    op.drop_constraint(None, 'resource', type_='foreignkey')
    op.drop_constraint(None, 'resource', type_='foreignkey')
    op.drop_column('resource', 'owner_id')
    op.drop_column('resource', 'manager_id')
    op.drop_column('resource', '_pks')
    op.create_table('relationship',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.VARCHAR(length=63), nullable=False),
    sa.Column('resource_id', sa.INTEGER(), nullable=True),
    sa.ForeignKeyConstraint(['resource_id'], ['resource.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('relationship_model')
    op.drop_table('manager')
    ### end Alembic commands ###
