"""Expand node information

Revision ID: 1b2fa9c97090
Revises: 30b9f619c3b2
Create Date: 2014-05-13 11:54:21.124565

"""

# revision identifiers, used by Alembic.
revision = '1b2fa9c97090'
down_revision = '30b9f619c3b2'

from alembic import op
import sqlalchemy as sa


def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'cluster',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('label', sa.String(length=128), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('label')
    )
    op.create_table(
        'cluster_node',
        sa.Column('cluster_id', sa.GUID(), nullable=False),
        sa.Column('node_id', sa.GUID(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['cluster_id'], ['cluster.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['node_id'], ['node.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('cluster_id', 'node_id')
    )
    op.add_column('node', sa.Column('data', sa.JSONEncodedDict(), nullable=True))


def downgrade():
    op.drop_column('node', 'data')
    op.drop_table('cluster_node')
    op.drop_table('cluster')
