text: """Initial migration v0.9
  
  Revision ID: 98f64c144070
  Revises: 
  Create Date: 2021-06-05 13:34:15.417403
  
  """
  from alembic import op
  import sqlalchemy as sa
  import app.db_models
  
  # revision identifiers, used by Alembic.
  revision = '98f64c144070'
  down_revision = None
  branch_labels = None
  depends_on = None
  
  
  def upgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.create_table('c_accepted_cipher_post_handshake_response',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('post_handshake_response', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('post_handshake_response')
      )
      op.create_table('c_rejected_cipher_handshake_error_message',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('handshake_error_message', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('handshake_error_message')
      )
      op.create_table('certificatechain',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('chain', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('chain')
      )
      op.create_table('certificates',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('as_pem', sa.String(), nullable=True),
      sa.Column('hpkp_pin', sa.String(), nullable=True),
      sa.Column('subject', sa.String(), nullable=True),
      sa.Column('issuer', sa.String(), nullable=True),
      sa.Column('serialNumber', sa.String(), nullable=True),
      sa.Column('thumbprint_sha1', sa.String(), nullable=True),
      sa.Column('thumbprint_sha256', sa.String(), nullable=True),
      sa.Column('notBefore', sa.DateTime(), nullable=True),
      sa.Column('notAfter', sa.DateTime(), nullable=True),
      sa.Column('signatureAlgorithm', sa.String(), nullable=True),
      sa.Column('publicKey_algorithm', sa.String(), nullable=True),
      sa.Column('publicKey_size', sa.Integer(), nullable=True),
      sa.Column('publicKey_curve', sa.String(), nullable=True),
      sa.Column('publicKey_exponent', sa.Integer(), nullable=True),
      sa.Column('subject_alternative_name_list', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id')
      )
      with op.batch_alter_table('certificates', schema=None) as batch_op:
          batch_op.create_index(batch_op.f('ix_certificates_thumbprint_sha256'), ['thumbprint_sha256'], unique=True)
  
      op.create_table('ciphers',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('openssl_name', sa.String(), nullable=True),
      sa.Column('ssl_version', sa.String(), nullable=True),
      sa.Column('is_anonymous', sa.Boolean(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('openssl_name', 'ssl_version', name='_uq_ciphers')
      )
      op.create_table('deflatecompression',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('compression_name', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('compression_name')
      )
      op.create_table('downgradeattack',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('supports_fallback_scsv', sa.Boolean(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('supports_fallback_scsv')
      )
      op.create_table('notificationssentlog',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('timestamp', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('sent_notification_id', sa.String(), nullable=False),
      sa.Column('channel', sa.String(), nullable=False),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('sent_notification_id', 'channel', name='_uq_notificationssentlog')
      )
      op.create_table('ocspresponse',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('responseStatus', sa.String(), nullable=True),
      sa.Column('version', sa.Integer(), nullable=True),
      sa.Column('responseType', sa.String(), nullable=True),
      sa.Column('responderID', sa.String(), nullable=True),
      sa.Column('producedAt', sa.DateTime(), nullable=True),
      sa.Column('responses_list', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('responseStatus', 'version', 'responseType', 'responderID', 'producedAt', 'responses_list', name='_uq_ocspresponse')
      )
      op.create_table('ocspresponse_single',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('certID_hashAlgorithm', sa.String(), nullable=True),
      sa.Column('certID_issuerNameHash', sa.String(), nullable=True),
      sa.Column('certID_issuerKeyHash', sa.String(), nullable=True),
      sa.Column('certID_serialNumber', sa.String(), nullable=True),
      sa.Column('certStatus', sa.String(), nullable=True),
      sa.Column('thisUpdate', sa.DateTime(), nullable=True),
      sa.Column('nextUpdate', sa.DateTime(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('certID_hashAlgorithm', 'certID_issuerNameHash', 'certID_issuerKeyHash', 'certID_serialNumber', 'certStatus', 'thisUpdate', 'nextUpdate', name='_uq_ocspresponse_single')
      )
      op.create_table('opensslccsinjection',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('is_vulnerable_to_ccs_injection', sa.Boolean(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('is_vulnerable_to_ccs_injection')
      )
      op.create_table('opensslheartbleed',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('is_vulnerable_to_heartbleed', sa.Boolean(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('is_vulnerable_to_heartbleed')
      )
      op.create_table('robotattack',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('robot_result_enum', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('robot_result_enum')
      )
      op.create_table('sessionrenegotiation',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('accepts_client_renegotiation', sa.Boolean(), nullable=True),
      sa.Column('supports_secure_renegotiation', sa.Boolean(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('accepts_client_renegotiation', 'supports_secure_renegotiation', name='_uq_sessionrenegotiation')
      )
      op.create_table('targets',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('hostname', sa.String(), nullable=False),
      sa.Column('port', sa.Integer(), nullable=True),
      sa.Column('ip_address', sa.String(), nullable=True),
      sa.Column('protocol', sa.Enum('PLAIN_TLS', 'HTTPS', 'STARTTLS_SMTP', 'STARTTLS_XMPP', 'STARTTLS_XMPP_SERVER', 'STARTTLS_FTP', 'STARTTLS_POP3', 'STARTTLS_LDAP', 'STARTTLS_IMAP', 'STARTTLS_RDP', 'STARTTLS_POSTGRES', name='tlswrappedprotocolenum'), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('hostname', 'port', 'ip_address', 'protocol', name='_uq_targets')
      )
      op.create_table('tls12_session_resumption_rate',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('attempted_resumptions_nb', sa.Integer(), nullable=True),
      sa.Column('successful_resumptions_nb', sa.Integer(), nullable=True),
      sa.Column('errored_resumptions_list', sa.String(), nullable=True),
      sa.Column('failed_resumptions_nb', sa.Integer(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('attempted_resumptions_nb', 'successful_resumptions_nb', 'errored_resumptions_list', 'failed_resumptions_nb', name='_uq_tls12_session_resumption_rate')
      )
      op.create_table('tls12_session_resumption_support',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('attempted_resumptions_nb', sa.Integer(), nullable=True),
      sa.Column('successful_resumptions_nb', sa.Integer(), nullable=True),
      sa.Column('errored_resumptions_list', sa.String(), nullable=True),
      sa.Column('failed_resumptions_nb', sa.Integer(), nullable=True),
      sa.Column('is_ticket_resumption_supported', sa.Boolean(), nullable=True),
      sa.Column('ticket_resumption_failed_reason', sa.String(), nullable=True),
      sa.Column('ticket_resumption_error', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('attempted_resumptions_nb', 'successful_resumptions_nb', 'errored_resumptions_list', 'failed_resumptions_nb', 'is_ticket_resumption_supported', 'ticket_resumption_failed_reason', 'ticket_resumption_error', name='_uq_tls12_session_resumption_support')
      )
      op.create_table('tls13_early_data',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('is_early_data_supported', sa.Boolean(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('is_early_data_supported')
      )
      op.create_table('truststores',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('name', sa.String(), nullable=True),
      sa.Column('version', sa.String(), nullable=True),
      sa.Column('ev_oids', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('name', 'version', 'ev_oids', name='_uq_truststores')
      )
      op.create_table('users',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('username', sa.String(), nullable=False),
      sa.Column('email', sa.String(), nullable=True),
      sa.Column('password_hash', sa.String(), nullable=True),
      sa.Column('main_api_key', sa.String(), nullable=True),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('main_api_key')
      )
      with op.batch_alter_table('users', schema=None) as batch_op:
          batch_op.create_index(batch_op.f('ix_users_username'), ['username'], unique=True)
  
      op.create_table('acceptedciphers',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('ciphersuite_id', sa.Integer(), nullable=True),
      sa.Column('key_size', sa.Integer(), nullable=True),
      sa.Column('post_handshake_response_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['ciphersuite_id'], ['ciphers.id'], ),
      sa.ForeignKeyConstraint(['post_handshake_response_id'], ['c_accepted_cipher_post_handshake_response.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('ciphersuite_id', 'key_size', 'post_handshake_response_id', name='_uq_acceptedciphers')
      )
      op.create_table('certificateinformation',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('path_validation_result_list', sa.String(), nullable=True),
      sa.Column('path_validation_error_list', sa.String(), nullable=True),
      sa.Column('leaf_certificate_subject_matches_hostname', sa.Boolean(), nullable=True),
      sa.Column('leaf_certificate_is_ev', sa.Boolean(), nullable=True),
      sa.Column('leaf_certificate_has_must_staple_extension', sa.Boolean(), nullable=True),
      sa.Column('leaf_certificate_signed_certificate_timestamps_count', sa.Integer(), nullable=True),
      sa.Column('received_chain_contains_anchor_certificate', sa.Boolean(), nullable=True),
      sa.Column('received_chain_has_valid_order', sa.Boolean(), nullable=True),
      sa.Column('verified_chain_has_sha1_signature', sa.Boolean(), nullable=True),
      sa.Column('verified_chain_has_legacy_symantec_anchor', sa.Boolean(), nullable=True),
      sa.Column('ocsp_response_id', sa.Integer(), nullable=True),
      sa.Column('ocsp_response_status', sa.String(), nullable=True),
      sa.Column('ocsp_response_is_trusted', sa.Boolean(), nullable=True),
      sa.Column('received_certificate_chain_list_id', sa.Integer(), nullable=True),
      sa.Column('verified_certificate_chain_list_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['ocsp_response_id'], ['ocspresponse.id'], ),
      sa.ForeignKeyConstraint(['received_certificate_chain_list_id'], ['certificatechain.id'], ),
      sa.ForeignKeyConstraint(['verified_certificate_chain_list_id'], ['certificatechain.id'], ),
      sa.PrimaryKeyConstraint('id')
      )
      op.create_table('connectionstatusoverrides',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('user_id', sa.Integer(), nullable=True),
      sa.Column('target_id', sa.Integer(), nullable=True),
      sa.Column('preferences', sa.JSON(), nullable=True),
      sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ),
      sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('user_id', 'target_id', name='_uq_connectionstatusoverrides')
      )
      op.create_table('httpsecurityheaders',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('strict_transport_security_header', sa.String(), nullable=True),
      sa.Column('public_key_pins_header', sa.String(), nullable=True),
      sa.Column('public_key_pins_report_only_header', sa.String(), nullable=True),
      sa.Column('expect_ct_header_max_age', sa.Integer(), nullable=True),
      sa.Column('expect_ct_header_report_uri', sa.String(), nullable=True),
      sa.Column('expect_ct_header_enforce', sa.Boolean(), nullable=True),
      sa.Column('is_valid_pin_configured', sa.String(), nullable=True),
      sa.Column('is_backup_pin_configured', sa.String(), nullable=True),
      sa.Column('verified_certificate_chain_list_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['verified_certificate_chain_list_id'], ['certificatechain.id'], ),
      sa.PrimaryKeyConstraint('id')
      )
      op.create_table('mailconnections',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('user_id', sa.Integer(), nullable=True),
      sa.Column('email', sa.String(), nullable=True),
      sa.Column('validated', sa.Boolean(), nullable=True),
      sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('user_id', 'email', name='_uq_mailconnections')
      )
      op.create_table('plaintextnotifications',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('user_id', sa.Integer(), nullable=True),
      sa.Column('target_id', sa.Integer(), nullable=True),
      sa.Column('channel', sa.String(), nullable=True),
      sa.Column('event_id', sa.String(), nullable=True),
      sa.Column('notification_id', sa.String(), nullable=True),
      sa.Column('msg', sa.JSON(), nullable=True),
      sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ),
      sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('notification_id')
      )
      with op.batch_alter_table('plaintextnotifications', schema=None) as batch_op:
          batch_op.create_index(batch_op.f('ix_plaintextnotifications_user_id'), ['user_id'], unique=False)
  
      op.create_table('rejectedciphers',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('ciphersuite_id', sa.Integer(), nullable=True),
      sa.Column('handshake_error_message_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['ciphersuite_id'], ['ciphers.id'], ),
      sa.ForeignKeyConstraint(['handshake_error_message_id'], ['c_rejected_cipher_handshake_error_message.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('ciphersuite_id', 'handshake_error_message_id', name='_uq_rejectedciphers')
      )
      op.create_table('scanorders',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('target_id', sa.Integer(), nullable=False),
      sa.Column('user_id', sa.Integer(), nullable=True),
      sa.Column('active', sa.Boolean(), nullable=True),
      sa.Column('periodicity', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ),
      sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('target_id', 'user_id', name='_uq_scanorders')
      )
      op.create_table('scanordersminimal',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('periodicity', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['id'], ['targets.id'], ),
      sa.PrimaryKeyConstraint('id')
      )
      op.create_table('scanresultssimplified',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('scanresult_id', sa.Integer(), nullable=True),
      sa.Column('notBefore', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('notAfter', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('grade', sa.String(), nullable=True),
      sa.Column('grade_reasons', sa.String(), nullable=True),
      sa.Column('received_certificate_chain_list_id', sa.Integer(), nullable=True),
      sa.Column('verified_certificate_chains_lists_ids', sa.String(), nullable=True),
      sa.Column('validated_against_truststores_list', sa.String(), nullable=True),
      sa.Column('sslv2_working_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('sslv2_working_weak_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('sslv3_working_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('sslv3_working_weak_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv10_working_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv10_working_weak_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv11_working_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv11_working_weak_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv12_working_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv12_working_weak_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv13_working_ciphers_count', sa.Integer(), nullable=True),
      sa.Column('tlsv13_working_weak_ciphers_count', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['received_certificate_chain_list_id'], ['certificatechain.id'], ),
      sa.PrimaryKeyConstraint('id')
      )
      with op.batch_alter_table('scanresultssimplified', schema=None) as batch_op:
          batch_op.create_index(batch_op.f('ix_scanresultssimplified_scanresult_id'), ['scanresult_id'], unique=False)
  
      op.create_table('serverinfos',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('hostname', sa.String(), nullable=True),
      sa.Column('port', sa.Integer(), nullable=True),
      sa.Column('ip_address', sa.String(), nullable=True),
      sa.Column('openssl_cipher_string_supported_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['openssl_cipher_string_supported_id'], ['ciphers.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('hostname', 'port', 'ip_address', 'openssl_cipher_string_supported_id', name='_uq_serverinfos')
      )
      op.create_table('slackconnections',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('user_id', sa.Integer(), nullable=True),
      sa.Column('channel_id', sa.String(), nullable=True),
      sa.Column('channel_name', sa.String(), nullable=True),
      sa.Column('team_id', sa.String(), nullable=True),
      sa.Column('team_name', sa.String(), nullable=True),
      sa.Column('access_token', sa.String(), nullable=True),
      sa.Column('webhook_url', sa.String(), nullable=True),
      sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('user_id', 'channel_id', 'team_id', name='_uq_slackconnections')
      )
      op.create_table('tmprandomcodes',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('timestamp', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('expires', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('user_id', sa.Integer(), nullable=True),
      sa.Column('code', sa.String(), nullable=True),
      sa.Column('activity', sa.String(), nullable=True),
      sa.Column('params', sa.String(), nullable=True),
      sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('code', name='_uq_tmprandomcodes')
      )
      with op.batch_alter_table('tmprandomcodes', schema=None) as batch_op:
          batch_op.create_index(batch_op.f('ix_tmprandomcodes_code'), ['code'], unique=True)
  
      op.create_table('validatedpaths',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('trust_store_id', sa.Integer(), nullable=True),
      sa.Column('chain_id', sa.Integer(), nullable=True),
      sa.Column('verify_string', sa.String(), nullable=True),
      sa.ForeignKeyConstraint(['chain_id'], ['certificatechain.id'], ),
      sa.ForeignKeyConstraint(['trust_store_id'], ['truststores.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('trust_store_id', 'chain_id', 'verify_string', name='_uq_validatedpaths')
      )
      op.create_table('ciphersuitescanresults',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('protocol', sa.String(), nullable=True),
      sa.Column('preferred_cipher_id', sa.Integer(), nullable=True),
      sa.Column('accepted_cipher_list', sa.String(), nullable=True),
      sa.Column('rejected_cipher_list', sa.String(), nullable=True),
      sa.Column('errored_cipher_list', sa.String(), nullable=True),
      sa.ForeignKeyConstraint(['preferred_cipher_id'], ['acceptedciphers.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('protocol', 'preferred_cipher_id', 'accepted_cipher_list', 'rejected_cipher_list', 'errored_cipher_list', name='_uq_ciphersuitescanresults')
      )
      op.create_table('scanresults',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('server_info_id', sa.Integer(), nullable=True),
      sa.Column('deflate_compression_id', sa.Integer(), nullable=True),
      sa.Column('session_renegotiation_id', sa.Integer(), nullable=True),
      sa.Column('tls_13_early_data_id', sa.Integer(), nullable=True),
      sa.Column('openssl_ccs_injection_id', sa.Integer(), nullable=True),
      sa.Column('openssl_heartbleed_id', sa.Integer(), nullable=True),
      sa.Column('downgrade_attacks_id', sa.Integer(), nullable=True),
      sa.Column('robot_attack_id', sa.Integer(), nullable=True),
      sa.Column('tls_12_session_resumption_rate_id', sa.Integer(), nullable=True),
      sa.Column('tls_12_session_resumption_support_id', sa.Integer(), nullable=True),
      sa.Column('http_security_headers_id', sa.Integer(), nullable=True),
      sa.Column('certificate_information_id', sa.Integer(), nullable=True),
      sa.Column('sslv2_id', sa.Integer(), nullable=True),
      sa.Column('sslv3_id', sa.Integer(), nullable=True),
      sa.Column('tlsv1_id', sa.Integer(), nullable=True),
      sa.Column('tlsv11_id', sa.Integer(), nullable=True),
      sa.Column('tlsv12_id', sa.Integer(), nullable=True),
      sa.Column('tlsv13_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['certificate_information_id'], ['certificateinformation.id'], ),
      sa.ForeignKeyConstraint(['deflate_compression_id'], ['deflatecompression.id'], ),
      sa.ForeignKeyConstraint(['downgrade_attacks_id'], ['downgradeattack.id'], ),
      sa.ForeignKeyConstraint(['http_security_headers_id'], ['httpsecurityheaders.id'], ),
      sa.ForeignKeyConstraint(['openssl_ccs_injection_id'], ['opensslccsinjection.id'], ),
      sa.ForeignKeyConstraint(['openssl_heartbleed_id'], ['opensslheartbleed.id'], ),
      sa.ForeignKeyConstraint(['robot_attack_id'], ['robotattack.id'], ),
      sa.ForeignKeyConstraint(['server_info_id'], ['serverinfos.id'], ),
      sa.ForeignKeyConstraint(['session_renegotiation_id'], ['sessionrenegotiation.id'], ),
      sa.ForeignKeyConstraint(['sslv2_id'], ['ciphersuitescanresults.id'], ),
      sa.ForeignKeyConstraint(['sslv3_id'], ['ciphersuitescanresults.id'], ),
      sa.ForeignKeyConstraint(['tls_12_session_resumption_rate_id'], ['tls12_session_resumption_rate.id'], ),
      sa.ForeignKeyConstraint(['tls_12_session_resumption_support_id'], ['tls12_session_resumption_support.id'], ),
      sa.ForeignKeyConstraint(['tls_13_early_data_id'], ['tls13_early_data.id'], ),
      sa.ForeignKeyConstraint(['tlsv11_id'], ['ciphersuitescanresults.id'], ),
      sa.ForeignKeyConstraint(['tlsv12_id'], ['ciphersuitescanresults.id'], ),
      sa.ForeignKeyConstraint(['tlsv13_id'], ['ciphersuitescanresults.id'], ),
      sa.ForeignKeyConstraint(['tlsv1_id'], ['ciphersuitescanresults.id'], ),
      sa.PrimaryKeyConstraint('id')
      )
      op.create_table('lastscan',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('target_id', sa.Integer(), nullable=True),
      sa.Column('last_scanned', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('last_enqueued', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('result_id', sa.Integer(), nullable=True),
      sa.ForeignKeyConstraint(['result_id'], ['scanresults.id'], ),
      sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('target_id'),
      sa.UniqueConstraint('target_id', name='_uq_lastscan')
      )
      op.create_table('scanresultshistory',
      sa.Column('id', sa.Integer(), nullable=False),
      sa.Column('timestamp', app.db_models.NumericTimestamp(), nullable=True),
      sa.Column('target_id', sa.Integer(), nullable=False),
      sa.Column('scanresult_id', sa.Integer(), nullable=False),
      sa.ForeignKeyConstraint(['scanresult_id'], ['scanresults.id'], ),
      sa.ForeignKeyConstraint(['target_id'], ['targets.id'], ),
      sa.PrimaryKeyConstraint('id'),
      sa.UniqueConstraint('target_id', 'scanresult_id', name='_uq_scanresultshistory')
      )
      # ### end Alembic commands ###
  
  
  def downgrade():
      # ### commands auto generated by Alembic - please adjust! ###
      op.drop_table('scanresultshistory')
      op.drop_table('lastscan')
      op.drop_table('scanresults')
      op.drop_table('ciphersuitescanresults')
      op.drop_table('validatedpaths')
      with op.batch_alter_table('tmprandomcodes', schema=None) as batch_op:
          batch_op.drop_index(batch_op.f('ix_tmprandomcodes_code'))
  
      op.drop_table('tmprandomcodes')
      op.drop_table('slackconnections')
      op.drop_table('serverinfos')
      with op.batch_alter_table('scanresultssimplified', schema=None) as batch_op:
          batch_op.drop_index(batch_op.f('ix_scanresultssimplified_scanresult_id'))
  
      op.drop_table('scanresultssimplified')
      op.drop_table('scanordersminimal')
      op.drop_table('scanorders')
      op.drop_table('rejectedciphers')
      with op.batch_alter_table('plaintextnotifications', schema=None) as batch_op:
          batch_op.drop_index(batch_op.f('ix_plaintextnotifications_user_id'))
  
      op.drop_table('plaintextnotifications')
      op.drop_table('mailconnections')
      op.drop_table('httpsecurityheaders')
      op.drop_table('connectionstatusoverrides')
      op.drop_table('certificateinformation')
      op.drop_table('acceptedciphers')
      with op.batch_alter_table('users', schema=None) as batch_op:
          batch_op.drop_index(batch_op.f('ix_users_username'))
  
      op.drop_table('users')
      op.drop_table('truststores')
      op.drop_table('tls13_early_data')
      op.drop_table('tls12_session_resumption_support')
      op.drop_table('tls12_session_resumption_rate')
      op.drop_table('targets')
      op.drop_table('sessionrenegotiation')
      op.drop_table('robotattack')
      op.drop_table('opensslheartbleed')
      op.drop_table('opensslccsinjection')
      op.drop_table('ocspresponse_single')
      op.drop_table('ocspresponse')
      op.drop_table('notificationssentlog')
      op.drop_table('downgradeattack')
      op.drop_table('deflatecompression')
      op.drop_table('ciphers')
      with op.batch_alter_table('certificates', schema=None) as batch_op:
          batch_op.drop_index(batch_op.f('ix_certificates_thumbprint_sha256'))
  
      op.drop_table('certificates')
      op.drop_table('certificatechain')
      op.drop_table('c_rejected_cipher_handshake_error_message')
      op.drop_table('c_accepted_cipher_post_handshake_response')
      # ### end Alembic commands ###
  