"""add kingdoms

Revision ID: ea6f4ddd78a9
Revises: e7a0ff5cc43c
Create Date: 2016-09-27 15:06:14.662950

"""

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

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('kingdom',
    sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('gen_random_uuid()'), nullable=False),
    sa.Column('created', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('deleted', sa.DateTime(), nullable=True),
    sa.Column('name', sa.String(length=256), nullable=False),
    sa.Column('creator', sa.String(length=256), nullable=False),
    sa.PrimaryKeyConstraint('uuid', name=op.f('pk_kingdom'))
    )
    op.create_table('kingdomcomment',
    sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('gen_random_uuid()'), nullable=False),
    sa.Column('created', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('deleted', sa.DateTime(), nullable=True),
    sa.Column('kingdom', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('author', sa.String(length=256), nullable=False),
    sa.ForeignKeyConstraint(['kingdom'], ['kingdom.uuid'], name=op.f('fk_kingdomcomment_kingdom_kingdom')),
    sa.PrimaryKeyConstraint('uuid', name=op.f('pk_kingdomcomment'))
    )
    op.create_table('kingdomrating',
    sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('gen_random_uuid()'), nullable=False),
    sa.Column('created', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('deleted', sa.DateTime(), nullable=True),
    sa.Column('kingdom', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('rating', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['kingdom'], ['kingdom.uuid'], name=op.f('fk_kingdomrating_kingdom_kingdom')),
    sa.PrimaryKeyConstraint('uuid', name=op.f('pk_kingdomrating'))
    )
    op.create_table('kingdomcard',
    sa.Column('uuid', postgresql.UUID(as_uuid=True), server_default=sa.text('gen_random_uuid()'), nullable=False),
    sa.Column('created', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('deleted', sa.DateTime(), nullable=True),
    sa.Column('kingdom', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('card', postgresql.UUID(as_uuid=True), nullable=False),
    sa.ForeignKeyConstraint(['card'], ['card.uuid'], name=op.f('fk_kingdomcard_card_card')),
    sa.ForeignKeyConstraint(['kingdom'], ['kingdom.uuid'], name=op.f('fk_kingdomcard_kingdom_kingdom')),
    sa.PrimaryKeyConstraint('uuid', name=op.f('pk_kingdomcard'))
    )
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('kingdomcard')
    op.drop_table('kingdomrating')
    op.drop_table('kingdomcomment')
    op.drop_table('kingdom')
    ### end Alembic commands ###
