"""remove old history tool

Revision ID: 09ec7dda0433
Revises: 40381d5477b5
Create Date: 2016-02-05 19:42:47.827900

"""

# revision identifiers, used by Alembic.
revision = '09ec7dda0433'
down_revision = '40381d5477b5'
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.drop_constraint('web_pages_previous_release_fkey', 'web_pages', type_='foreignkey')
    op.drop_column('web_pages', 'previous_release')
    op.drop_table('web_page_history')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('web_pages', sa.Column('previous_release', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('web_pages_previous_release_fkey', 'web_pages', 'web_page_history', ['previous_release'], ['id'])
    op.create_table('web_page_history',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('errno', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('url', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('file', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('distance', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('is_text', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('title', citext.CIText(), autoincrement=False, nullable=True),
    sa.Column('mimetype', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('content', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('fetchtime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('addtime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('tsv_content', postgresql.TSVECTOR(), autoincrement=False, nullable=True),
    sa.Column('root_rel', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('newer_rel', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('older_rel', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('contenthash', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('is_diff', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['file'], ['web_files.id'], name='web_page_history_file_fkey'),
    sa.ForeignKeyConstraint(['newer_rel'], ['web_page_history.id'], name='web_page_history_newer_rel_fkey'),
    sa.ForeignKeyConstraint(['older_rel'], ['web_page_history.id'], name='web_page_history_older_rel_fkey'),
    sa.ForeignKeyConstraint(['root_rel'], ['web_pages.id'], name='web_page_history_root_rel_fkey'),
    sa.PrimaryKeyConstraint('id', name='web_page_history_pkey')
    )
    ### end Alembic commands ###

"""remove old history tool

Revision ID: 09ec7dda0433
Revises: 40381d5477b5
Create Date: 2016-02-05 19:42:47.827900

"""

# revision identifiers, used by Alembic.
revision = '09ec7dda0433'
down_revision = '40381d5477b5'
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.drop_constraint('web_pages_previous_release_fkey', 'web_pages', type_='foreignkey')
    op.drop_column('web_pages', 'previous_release')
    op.drop_table('web_page_history')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('web_pages', sa.Column('previous_release', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('web_pages_previous_release_fkey', 'web_pages', 'web_page_history', ['previous_release'], ['id'])
    op.create_table('web_page_history',
    sa.Column('id', sa.INTEGER(), nullable=False),
    sa.Column('errno', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('url', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('file', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('distance', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('is_text', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.Column('title', citext.CIText(), autoincrement=False, nullable=True),
    sa.Column('mimetype', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('content', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('fetchtime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('addtime', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('tsv_content', postgresql.TSVECTOR(), autoincrement=False, nullable=True),
    sa.Column('root_rel', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('newer_rel', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('older_rel', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('contenthash', sa.TEXT(), autoincrement=False, nullable=True),
    sa.Column('is_diff', sa.BOOLEAN(), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['file'], ['web_files.id'], name='web_page_history_file_fkey'),
    sa.ForeignKeyConstraint(['newer_rel'], ['web_page_history.id'], name='web_page_history_newer_rel_fkey'),
    sa.ForeignKeyConstraint(['older_rel'], ['web_page_history.id'], name='web_page_history_older_rel_fkey'),
    sa.ForeignKeyConstraint(['root_rel'], ['web_pages.id'], name='web_page_history_root_rel_fkey'),
    sa.PrimaryKeyConstraint('id', name='web_page_history_pkey')
    )
    ### end Alembic commands ###

remove old history tool  Revision ID: 09ec7dda0433 Revises: 40381d5477b5 Create Date: 2016-02-05 19:42:47.827900 # revision identifiers, used by Alembic. # Patch in knowledge of the citext type, so it reflects properly. ### commands auto generated by Alembic - please adjust! ### ### end Alembic commands ### ### commands auto generated by Alembic - please adjust! ### ### end Alembic commands ###