"""Auto migration

Revision ID: 3accc1da627b
Revises: 
Create Date: 2021-01-19 14:48:39.929974

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '3accc1da627b'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('dim_field',
    sa.Column('field_key', sa.Integer(), nullable=False),
    sa.Column('project_id', sa.String(length=255), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('control_type', sa.String(length=255), nullable=True),
    sa.Column('default_value', sa.String(length=255), nullable=True),
    sa.Column('counted_character', sa.Boolean(), nullable=False),
    sa.Column('counted_character_date_from_key', sa.Integer(), nullable=False),
    sa.Column('counted_character_time_from_key', sa.Integer(), nullable=False),
    sa.Column('counted_character_date_to_key', sa.Integer(), nullable=False),
    sa.Column('counted_character_time_to_key', sa.Integer(), nullable=False),
    sa.Column('is_sub_field', sa.Boolean(), nullable=False),
    sa.PrimaryKeyConstraint('field_key'),
    schema='dwh_development_analytic'
    )
    op.create_table('dim_process',
    sa.Column('process_key', sa.Integer(), nullable=False),
    sa.Column('module', sa.String(length=255), nullable=True),
    sa.Column('type', sa.String(length=255), nullable=True),
    sa.Column('step', sa.String(length=255), nullable=True),
    sa.Column('sub_step', sa.String(length=255), nullable=True),
    sa.Column('resource', sa.String(length=255), nullable=True),
    sa.Column('description', sa.String(length=500), nullable=True),
    sa.PrimaryKeyConstraint('process_key'),
    schema='dwh_development_analytic'
    )
    op.create_table('dim_project_variable',
    sa.Column('project_id', sa.String(length=255), nullable=False),
    sa.Column('project_name', sa.String(length=255), nullable=False),
    sa.Column('docs_collection_name', sa.String(length=255), nullable=True),
    sa.Column('trans_collection_name', sa.String(length=255), nullable=True),
    sa.Column('performance_collection_name', sa.String(length=255), nullable=True),
    sa.Column('field_collection_name', sa.String(length=255), nullable=True),
    sa.Column('docs_query', sa.String(length=500), nullable=True),
    sa.Column('trans_query', sa.String(length=500), nullable=True),
    sa.Column('performance_query', sa.String(length=500), nullable=True),
    sa.Column('field_query', sa.String(length=500), nullable=True),
    sa.Column('project_backup_dir', sa.String(length=255), nullable=True),
    sa.Column('project_docs_dir', sa.String(length=255), nullable=True),
    sa.Column('project_trans_dir', sa.String(length=255), nullable=True),
    sa.Column('project_performance_dir', sa.String(length=255), nullable=False),
    sa.Column('project_field_dir', sa.String(length=255), nullable=False),
    sa.Column('backup_file_type', sa.String(length=255), nullable=True),
    sa.Column('schedule_type', sa.String(length=255), nullable=True),
    sa.Column('schedule_date_key', sa.Integer(), nullable=True),
    sa.Column('schedule_time_key', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('project_id'),
    schema='dwh_development_analytic'
    )
    op.create_table('fact_data_extraction',
    sa.Column('data_extraction_key', sa.BigInteger(), nullable=False),
    sa.Column('performance_key', sa.BigInteger(), nullable=True),
    sa.Column('document_key', sa.BigInteger(), nullable=True),
    sa.Column('ori_document_id', sa.String(length=255), nullable=True),
    sa.Column('project_id', sa.String(length=255), nullable=False),
    sa.Column('document_id', sa.String(length=255), nullable=True),
    sa.Column('doc_set_id', sa.String(length=255), nullable=True),
    sa.Column('record_id', sa.Integer(), nullable=True),
    sa.Column('last_modified_time_key', sa.Integer(), nullable=True),
    sa.Column('last_modified_date_key', sa.Integer(), nullable=True),
    sa.Column('user_name', sa.String(length=255), nullable=True),
    sa.Column('process_key', sa.Integer(), nullable=True),
    sa.Column('field_name', sa.String(length=255), nullable=False),
    sa.Column('field_value', sa.String(length=255), nullable=True),
    sa.Column('last_modified_timestamp', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('data_extraction_key'),
    schema='dwh_development_analytic'
    )
    # op.create_index(op.f('ix_dwh_development_analytic_fact_data_extraction_document_key'), 'fact_data_extraction', ['document_key'], unique=False, schema='dwh_development_analytic')
    op.create_table('fact_document',
    sa.Column('document_key', sa.BigInteger(), nullable=False),
    sa.Column('ori_document_id', sa.String(length=255), nullable=False),
    sa.Column('project_id', sa.String(length=255), nullable=False),
    sa.Column('document_id', sa.String(length=255), nullable=False),
    sa.Column('doc_set_id', sa.String(length=255), nullable=True),
    sa.Column('import_time_key', sa.Integer(), nullable=True),
    sa.Column('import_date_key', sa.Integer(), nullable=True),
    sa.Column('export_time_key', sa.Integer(), nullable=True),
    sa.Column('export_date_key', sa.Integer(), nullable=True),
    sa.Column('import_timestamp', sa.DateTime(), nullable=True),
    sa.Column('export_timestamp', sa.DateTime(), nullable=False),
    sa.Column('remark_code', sa.String(length=255), nullable=True),
    sa.Column('remark_description', sa.String(length=500), nullable=True),
    sa.PrimaryKeyConstraint('document_key'),
    schema='dwh_development_analytic'
    )
    op.create_table('fact_etl_report',
    sa.Column('report_key', sa.Integer(), nullable=False),
    sa.Column('project_id', sa.String(length=255), nullable=False),
    sa.Column('job_name', sa.String(length=255), nullable=False),
    sa.Column('schedule_type', sa.String(length=255), nullable=False),
    sa.Column('schedule_time_key', sa.String(length=255), nullable=True),
    sa.Column('schedule_date_key', sa.Integer(), nullable=True),
    sa.Column('executor_date_timestamp', sa.DateTime(), nullable=True),
    sa.Column('executor_date_key', sa.Integer(), nullable=True),
    sa.Column('executor_time_key', sa.Integer(), nullable=True),
    sa.Column('status_code', sa.String(length=255), nullable=True),
    sa.Column('description', sa.String(length=500), nullable=True),
    sa.Column('total_time_run_second', sa.Integer(), nullable=False),
    sa.PrimaryKeyConstraint('report_key'),
    schema='dwh_development_analytic'
    )
    op.create_table('fact_performance',
    sa.Column('performance_key', sa.BigInteger(), nullable=False),
    sa.Column('document_key', sa.BigInteger(), nullable=True),
    sa.Column('ori_performance_id', sa.String(length=255), nullable=False),
    sa.Column('group_id', sa.String(length=255), nullable=True),
    sa.Column('project_id', sa.String(length=255), nullable=True),
    sa.Column('document_id', sa.String(length=255), nullable=True),
    sa.Column('reworked', sa.Boolean(), nullable=False),
    sa.Column('work_type_key', sa.Integer(), nullable=False),
    sa.Column('process_key', sa.Integer(), nullable=True),
    sa.Column('user_name', sa.String(length=255), nullable=False),
    sa.Column('ip', sa.String(length=255), nullable=True),
    sa.Column('captured_date_timestamp', sa.DateTime(), nullable=False),
    sa.Column('captured_date_key', sa.Integer(), nullable=False),
    sa.Column('captured_time_key', sa.Integer(), nullable=False),
    sa.Column('total_time_second', sa.Integer(), nullable=False),
    sa.Column('number_of_record', sa.Integer(), nullable=True),
    sa.Column('number_of_item', sa.Integer(), nullable=True),
    sa.Column('number_of_field', sa.Integer(), nullable=True),
    sa.Column('number_of_character', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('performance_key'),
    schema='dwh_development_analytic'
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('fact_performance', schema='dwh_development_analytic')
    op.drop_table('fact_etl_report', schema='dwh_development_analytic')
    op.drop_table('fact_document', schema='dwh_development_analytic')
    op.drop_index(op.f('ix_dwh_development_analytic_fact_data_extraction_document_key'), table_name='fact_data_extraction', schema='dwh_development_analytic')
    op.drop_table('fact_data_extraction', schema='dwh_development_analytic')
    op.drop_table('dim_project_variable', schema='dwh_development_analytic')
    op.drop_table('dim_process', schema='dwh_development_analytic')
    op.drop_table('dim_field', schema='dwh_development_analytic')
    # ### end Alembic commands ###
