"""initial commit

Revision ID: 62764768d089
Revises: 
Create Date: 2021-01-04 15:03:01.147483

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy_utils import UUIDType

# revision identifiers, used by Alembic.
revision = '62764768d089'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('malpedia_actor_cfrsuspectedvictims',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('victim', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'victim')
    )
    op.create_table('malpedia_actor_cfrtargetcategory',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('category', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'category')
    )
    op.create_table('malpedia_actor_meta',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('shortname', sa.Text(), nullable=True),
    sa.Column('commonname', sa.Text(), nullable=True),
    sa.Column('country', sa.Text(), nullable=True),
    sa.Column('victimology', sa.Text(), nullable=True),
    sa.Column('cfrtypeofincident', sa.Text(), nullable=True),
    sa.Column('cfrstatesponsor', sa.Text(), nullable=True),
    sa.Column('since', sa.Text(), nullable=True),
    sa.Column('modeofoperation', sa.Text(), nullable=True),
    sa.Column('capabilities', sa.Text(), nullable=True),
    sa.Column('last_update', sa.Text(), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('uuid')
    )
    op.create_index(op.f('ix_malpedia_actor_meta_commonname'), 'malpedia_actor_meta', ['commonname'], unique=False)
    op.create_index(op.f('ix_malpedia_actor_meta_uuid'), 'malpedia_actor_meta', ['uuid'], unique=False)
    op.create_table('malpedia_malware_attribution',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('attribution', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'attribution')
    )
    op.create_table('malpedia_malware_meta',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('name', sa.Text(), nullable=True),
    sa.Column('commonname', sa.Text(), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('updated', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('uuid')
    )
    op.create_index(op.f('ix_malpedia_malware_meta_name'), 'malpedia_malware_meta', ['name'], unique=False)
    op.create_index(op.f('ix_malpedia_malware_meta_uuid'), 'malpedia_malware_meta', ['uuid'], unique=False)
    op.create_table('malpedia_malware_yara_path',
    sa.Column('uuid', UUIDType(), nullable=True),
    sa.Column('attribute_uuid', UUIDType(), nullable=True),
    sa.Column('tlp', sa.Text(), nullable=True),
    sa.Column('path_to_yara', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('path_to_yara')
    )
    op.create_index(op.f('ix_malpedia_malware_yara_path_uuid'), 'malpedia_malware_yara_path', ['uuid'], unique=False)
    op.create_table('malpedia_parent_child_by_uuid',
    sa.Column('uuid', UUIDType(), nullable=True),
    sa.Column('parentuuid', UUIDType(), nullable=True),
    sa.Column('name', sa.Text(), nullable=False),
    sa.Column('parentname', sa.Text(), nullable=False),
    sa.Column('isfile', sa.Boolean(), nullable=True),
    sa.Column('path', sa.Text(), nullable=True),
    sa.Column('version', sa.Text(), nullable=True),
    sa.Column('date_added', sa.Text(), nullable=True),
    sa.Column('mytype', sa.Text(), nullable=True),
    sa.Column('parent_type', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('name', 'parentname')
    )
    op.create_index(op.f('ix_malpedia_parent_child_by_uuid_mytype'), 'malpedia_parent_child_by_uuid', ['mytype'], unique=False)
    op.create_index(op.f('ix_malpedia_parent_child_by_uuid_name'), 'malpedia_parent_child_by_uuid', ['name'], unique=False)
    op.create_index(op.f('ix_malpedia_parent_child_by_uuid_parentuuid'), 'malpedia_parent_child_by_uuid', ['parentuuid'], unique=False)
    op.create_index(op.f('ix_malpedia_parent_child_by_uuid_uuid'), 'malpedia_parent_child_by_uuid', ['uuid'], unique=False)
    op.create_table('malpedia_references',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('url', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'url')
    )
    op.create_index(op.f('ix_malpedia_references_url'), 'malpedia_references', ['url'], unique=False)
    op.create_index(op.f('ix_malpedia_references_uuid'), 'malpedia_references', ['uuid'], unique=False)
    op.create_table('malpedia_tags',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('galaxy', sa.Text(), nullable=False),
    sa.Column('tag', sa.Text(), nullable=False),
    sa.Column('type', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'galaxy', 'tag', 'type')
    )
    op.create_table('manual_tag_maps',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('tagvalue', sa.Text(), nullable=False),
    sa.Column('galaxy', sa.Text(), nullable=True),
    sa.Column('tag', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('uuid', 'tagvalue')
    )
    op.create_index(op.f('ix_manual_tag_maps_galaxy'), 'manual_tag_maps', ['galaxy'], unique=False)
    op.create_index(op.f('ix_manual_tag_maps_tagvalue'), 'manual_tag_maps', ['tagvalue'], unique=False)
    op.create_index(op.f('ix_manual_tag_maps_uuid'), 'manual_tag_maps', ['uuid'], unique=False)
    op.create_table('misp_galaxy_clusters',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('galaxy', sa.Text(), nullable=False),
    sa.Column('tag', sa.Text(), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('uuid', 'galaxy', 'tag')
    )
    op.create_index(op.f('ix_misp_galaxy_clusters_galaxy'), 'misp_galaxy_clusters', ['galaxy'], unique=False)
    op.create_index(op.f('ix_misp_galaxy_clusters_tag'), 'misp_galaxy_clusters', ['tag'], unique=False)
    op.create_table('mitre_software_xref',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('mitreid', sa.Text(), nullable=True),
    sa.Column('mitrename', sa.Text(), nullable=False),
    sa.Column('mitrecode', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'mitrename', 'mitrecode')
    )
    op.create_index(op.f('ix_mitre_software_xref_mitrename'), 'mitre_software_xref', ['mitrename'], unique=False)
    op.create_table('synonyms',
    sa.Column('uuid', UUIDType(), nullable=False),
    sa.Column('synonym', sa.Text(), nullable=False),
    sa.Column('source', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('uuid', 'synonym', 'source')
    )
    op.create_index(op.f('ix_synonyms_uuid'), 'synonyms', ['uuid'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_synonyms_uuid'), table_name='synonyms')
    op.drop_table('synonyms')
    op.drop_index(op.f('ix_mitre_software_xref_mitrename'), table_name='mitre_software_xref')
    op.drop_table('mitre_software_xref')
    op.drop_index(op.f('ix_misp_galaxy_clusters_tag'), table_name='misp_galaxy_clusters')
    op.drop_index(op.f('ix_misp_galaxy_clusters_galaxy'), table_name='misp_galaxy_clusters')
    op.drop_table('misp_galaxy_clusters')
    op.drop_index(op.f('ix_manual_tag_maps_uuid'), table_name='manual_tag_maps')
    op.drop_index(op.f('ix_manual_tag_maps_tagvalue'), table_name='manual_tag_maps')
    op.drop_index(op.f('ix_manual_tag_maps_galaxy'), table_name='manual_tag_maps')
    op.drop_table('manual_tag_maps')
    op.drop_table('malpedia_tags')
    op.drop_index(op.f('ix_malpedia_references_uuid'), table_name='malpedia_references')
    op.drop_index(op.f('ix_malpedia_references_url'), table_name='malpedia_references')
    op.drop_table('malpedia_references')
    op.drop_index(op.f('ix_malpedia_parent_child_by_uuid_uuid'), table_name='malpedia_parent_child_by_uuid')
    op.drop_index(op.f('ix_malpedia_parent_child_by_uuid_parentuuid'), table_name='malpedia_parent_child_by_uuid')
    op.drop_index(op.f('ix_malpedia_parent_child_by_uuid_name'), table_name='malpedia_parent_child_by_uuid')
    op.drop_index(op.f('ix_malpedia_parent_child_by_uuid_mytype'), table_name='malpedia_parent_child_by_uuid')
    op.drop_table('malpedia_parent_child_by_uuid')
    op.drop_index(op.f('ix_malpedia_malware_yara_path_uuid'), table_name='malpedia_malware_yara_path')
    op.drop_table('malpedia_malware_yara_path')
    op.drop_index(op.f('ix_malpedia_malware_meta_uuid'), table_name='malpedia_malware_meta')
    op.drop_index(op.f('ix_malpedia_malware_meta_name'), table_name='malpedia_malware_meta')
    op.drop_table('malpedia_malware_meta')
    op.drop_table('malpedia_malware_attribution')
    op.drop_index(op.f('ix_malpedia_actor_meta_uuid'), table_name='malpedia_actor_meta')
    op.drop_index(op.f('ix_malpedia_actor_meta_commonname'), table_name='malpedia_actor_meta')
    op.drop_table('malpedia_actor_meta')
    op.drop_table('malpedia_actor_cfrtargetcategory')
    op.drop_table('malpedia_actor_cfrsuspectedvictims')
    # ### end Alembic commands ###
