"""init

Revision ID: f773309b2ee4
Revises: 
Create Date: 2017-05-08 00:52:29.336147

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'f773309b2ee4'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('group',
    sa.Column('name', sa.String(length=36), nullable=False),
    sa.PrimaryKeyConstraint('name')
    )
    op.create_table('group_relation',
    sa.Column('parent', sa.String(length=36), nullable=False),
    sa.Column('child', sa.String(length=36), nullable=False),
    sa.ForeignKeyConstraint(['child'], ['group.name'], onupdate='RESTRICT', ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['parent'], ['group.name'], onupdate='RESTRICT', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('parent', 'child')
    )
    op.create_table('user',
    sa.Column('name', sa.String(length=36), nullable=False),
    sa.Column('group_name', sa.String(length=36), nullable=True),
    sa.Column('attrs', sa.JSON(), nullable=True),
    sa.ForeignKeyConstraint(['group_name'], ['group.name'], onupdate='RESTRICT', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('name')
    )
    # ### end Alembic commands ###


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