"""empty message

Revision ID: 7f63439f1380
Revises: 62f3c5b2444b
Create Date: 2016-09-07 04:28:15.024047

"""

# revision identifiers, used by Alembic.
revision = '7f63439f1380'
down_revision = '62f3c5b2444b'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa

from sqlalchemy_utils.types import TSVectorType
from sqlalchemy_searchable import make_searchable
import sqlalchemy_utils

# Patch in knowledge of the citext type, so it reflects properly.
from sqlalchemy.dialects.postgresql.base import ischema_names
import citext
import queue
import datetime
from sqlalchemy.dialects.postgresql import ENUM
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy.dialects.postgresql import TSVECTOR
ischema_names['citext'] = citext.CIText

from sqlalchemy.dialects import postgresql

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('raw_web_pages',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('state', postgresql.ENUM('new', 'fetching', 'processing', 'complete', 'error', 'removed', 'disabled', 'specialty_deferred', 'specialty_ready', name='dlstate_enum', create_type=False), nullable=False),
        sa.Column('errno', sa.Integer(), nullable=True),
        sa.Column('url', sa.Text(), nullable=False),
        sa.Column('starturl', sa.Text(), nullable=False),
        sa.Column('netloc', sa.Text(), nullable=False),
        sa.Column('priority', sa.Integer(), nullable=False),
        sa.Column('distance', sa.Integer(), nullable=False),
        sa.Column('is_text', sa.Boolean(), nullable=True),
        sa.Column('mimetype', sa.Text(), nullable=True),
        sa.Column('filename', sa.Text(), nullable=True),
        sa.Column('fspath', sa.Text(), nullable=False),
        sa.Column('fetchtime', sa.DateTime(), nullable=True),
        sa.Column('addtime', sa.DateTime(), nullable=True),
        sa.Column('ignoreuntiltime', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_raw_web_pages_distance'), 'raw_web_pages', ['distance'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_id'), 'raw_web_pages', ['id'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_netloc'), 'raw_web_pages', ['netloc'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_priority'), 'raw_web_pages', ['priority'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_state'), 'raw_web_pages', ['state'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_url'), 'raw_web_pages', ['url'], unique=True)
    op.create_table('raw_web_pages_version',
        sa.Column('id', sa.Integer(), autoincrement=False, nullable=False),
        sa.Column('state', postgresql.ENUM('new', 'fetching', 'processing', 'complete', 'error', 'removed', 'disabled', 'specialty_deferred', 'specialty_ready', name='dlstate_enum', create_type=False), autoincrement=False, nullable=True),
        sa.Column('errno', sa.Integer(), autoincrement=False, nullable=True),
        sa.Column('url', sa.Text(), autoincrement=False, nullable=True),
        sa.Column('starturl', sa.Text(), autoincrement=False, nullable=True),
        sa.Column('netloc', sa.Text(), autoincrement=False, nullable=True),
        sa.Column('priority', sa.Integer(), autoincrement=False, nullable=True),
        sa.Column('distance', sa.Integer(), autoincrement=False, nullable=True),
        sa.Column('is_text', sa.Boolean(), autoincrement=False, nullable=True),
        sa.Column('mimetype', sa.Text(), autoincrement=False, nullable=True),
        sa.Column('filename', sa.Text(), autoincrement=False, nullable=True),
        sa.Column('fspath', sa.Text(), autoincrement=False, nullable=True),
        sa.Column('fetchtime', sa.DateTime(), autoincrement=False, nullable=True),
        sa.Column('addtime', sa.DateTime(), autoincrement=False, nullable=True),
        sa.Column('ignoreuntiltime', sa.DateTime(), autoincrement=False, nullable=True),
        sa.Column('transaction_id', sa.BigInteger(), autoincrement=False, nullable=False),
        sa.Column('end_transaction_id', sa.BigInteger(), nullable=True),
        sa.Column('operation_type', sa.SmallInteger(), nullable=False),
        sa.PrimaryKeyConstraint('id', 'transaction_id')
    )
    op.create_index(op.f('ix_raw_web_pages_version_distance'), 'raw_web_pages_version', ['distance'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_end_transaction_id'), 'raw_web_pages_version', ['end_transaction_id'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_id'), 'raw_web_pages_version', ['id'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_netloc'), 'raw_web_pages_version', ['netloc'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_operation_type'), 'raw_web_pages_version', ['operation_type'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_priority'), 'raw_web_pages_version', ['priority'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_state'), 'raw_web_pages_version', ['state'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_transaction_id'), 'raw_web_pages_version', ['transaction_id'], unique=False)
    op.create_index(op.f('ix_raw_web_pages_version_url'), 'raw_web_pages_version', ['url'], unique=False)
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_raw_web_pages_version_url'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_transaction_id'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_state'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_priority'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_operation_type'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_netloc'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_id'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_end_transaction_id'), table_name='raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_version_distance'), table_name='raw_web_pages_version')
    op.drop_table('raw_web_pages_version')
    op.drop_index(op.f('ix_raw_web_pages_url'), table_name='raw_web_pages')
    op.drop_index(op.f('ix_raw_web_pages_state'), table_name='raw_web_pages')
    op.drop_index(op.f('ix_raw_web_pages_priority'), table_name='raw_web_pages')
    op.drop_index(op.f('ix_raw_web_pages_netloc'), table_name='raw_web_pages')
    op.drop_index(op.f('ix_raw_web_pages_id'), table_name='raw_web_pages')
    op.drop_index(op.f('ix_raw_web_pages_distance'), table_name='raw_web_pages')
    op.drop_table('raw_web_pages')
    ### end Alembic commands ###
