""" Initial schema

Revision ID: 629958e9b907
Revises: 
Create Date: 2017-01-01 17:20:08.514311

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

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('iiif_image',
    sa.Column('surrogate_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.String(), nullable=True),
    sa.Column('info', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.PrimaryKeyConstraint('surrogate_id'),
    sa.UniqueConstraint('id')
    )
    op.create_table('manifest',
    sa.Column('surrogate_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.String(), nullable=True),
    sa.Column('origin', sa.String(), nullable=True),
    sa.Column('manifest', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
    sa.Column('label', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('surrogate_id'),
    sa.UniqueConstraint('id'),
    sa.UniqueConstraint('origin')
    )
    op.create_table('identifier',
    sa.Column('surrogate_id', sa.Integer(), nullable=False),
    sa.Column('id', sa.String(), nullable=True),
    sa.Column('type', sa.String(), nullable=True),
    sa.Column('manifest_id', sa.String(), nullable=False),
    sa.ForeignKeyConstraint(['manifest_id'], ['manifest.id'], ),
    sa.PrimaryKeyConstraint('surrogate_id'),
    sa.UniqueConstraint('id')
    )
    op.create_table('image',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('url', sa.String(), nullable=True),
    sa.Column('width', sa.Integer(), nullable=True),
    sa.Column('height', sa.Integer(), nullable=True),
    sa.Column('format', sa.Text(), nullable=True),
    sa.Column('iiif_id', sa.String(length=22), nullable=True),
    sa.ForeignKeyConstraint(['iiif_id'], ['iiif_image.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('url')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('image')
    op.drop_table('identifier')
    op.drop_table('manifest')
    op.drop_table('iiif_image')
    # ### end Alembic commands ###
