<gh_stars>0
"""empty message

Revision ID: <KEY>
Revises: <PASSWORD>
Create Date: 2021-12-28 21:12:20.185905

"""

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '9<PASSWORD>'

from alembic import op
import sqlalchemy as sa
import polylogyx.db.database
import flask_authorize

from sqlalchemy.dialects import postgresql


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('platform_activity',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('action', sa.String(), nullable=True),
    sa.Column('text', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('node_id', sa.Integer(), nullable=True),
    sa.Column('alert_id', sa.Integer(), nullable=True),
    sa.Column('rule_id', sa.Integer(), nullable=True),
    sa.Column('tag_id', sa.Integer(), nullable=True),
    sa.Column('query_id', sa.Integer(), nullable=True),
    sa.Column('pack_id', sa.Integer(), nullable=True),
    sa.Column('config_id', sa.Integer(), nullable=True),
    sa.Column('settings_id', sa.Integer(), nullable=True),
    sa.Column('default_filters_id', sa.Integer(), nullable=True),
    sa.Column('default_query_id', sa.Integer(), nullable=True),
    sa.Column('node_config_id', sa.Integer(), nullable=True),
    sa.Column('threat_intel_credentials_id', sa.Integer(), nullable=True),
    sa.Column('virus_total_av_engines_id', sa.Integer(), nullable=True),
    sa.Column('ioc_intel_id', sa.Integer(), nullable=True),
    sa.Column('carve_session_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['alert_id'], ['alerts.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['node_id'], ['node.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['config_id'], ['config.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['default_filters_id'], ['default_filters.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['default_query_id'], ['default_query.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['ioc_intel_id'], ['ioc_intel.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['carve_session_id'], ['carve_session.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['node_config_id'], ['node_config.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['pack_id'], ['pack.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['query_id'], ['query.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['rule_id'], ['rule.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['settings_id'], ['settings.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['threat_intel_credentials_id'], ['threat_intel_credentials.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['virus_total_av_engines_id'], ['virus_total_av_engines.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )

    op.add_column('distributed_query', sa.Column('owner_id', sa.Integer(), nullable=True))
    op.add_column('distributed_query', sa.Column('owner_permissions', flask_authorize.mixins.PipedList(), nullable=True))
    op.create_foreign_key(None, 'distributed_query', 'user', ['owner_id'], ['id'])

    op.add_column('alerts', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('default_query', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('default_query', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('distributed_query', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('distributed_query', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('groups', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('groups', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('node_config', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('pack', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('pack', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('query', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('query', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('roles', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('roles', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('rule', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('tag', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('tag', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('threat_intel_credentials', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('threat_intel_credentials', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.alter_column('user', 'created_at', existing_type=postgresql.TIMESTAMP(), nullable=True)
    op.add_column('virus_total_av_engines', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('virus_total_av_engines', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('ioc_intel', sa.Column('updated_at', sa.DateTime(), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('ioc_intel', 'updated_at')
    op.drop_column('virus_total_av_engines', 'updated_at')
    op.drop_column('virus_total_av_engines', 'created_at')
    op.alter_column('user', 'created_at', existing_type=postgresql.TIMESTAMP(), nullable=True)
    op.drop_column('threat_intel_credentials', 'updated_at')
    op.drop_column('threat_intel_credentials', 'created_at')
    op.drop_column('tag', 'updated_at')
    op.drop_column('tag', 'created_at')
    op.drop_column('rule', 'created_at')
    op.drop_column('roles', 'updated_at')
    op.drop_column('roles', 'created_at')
    op.drop_column('query', 'updated_at')
    op.drop_column('query', 'created_at')
    op.drop_column('pack', 'updated_at')
    op.drop_column('pack', 'created_at')
    op.drop_column('node_config', 'created_at')
    op.drop_column('groups', 'updated_at')
    op.drop_column('groups', 'created_at')
    op.drop_column('distributed_query', 'updated_at')
    op.drop_column('distributed_query', 'created_at')
    op.drop_column('default_query', 'updated_at')
    op.drop_column('default_query', 'created_at')
    op.drop_column('alerts', 'updated_at')

    op.drop_constraint(None, 'distributed_query', type_='foreignkey')
    op.drop_column('distributed_query', 'owner_permissions')
    op.drop_column('distributed_query', 'owner_id')

    op.drop_table('platform_activity')
    # ### end Alembic commands ###

"""empty message

Revision ID: <KEY>
Revises: <PASSWORD>
Create Date: 2021-12-28 21:12:20.185905

"""

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '9<PASSWORD>'

from alembic import op
import sqlalchemy as sa
import polylogyx.db.database
import flask_authorize

from sqlalchemy.dialects import postgresql


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('platform_activity',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('action', sa.String(), nullable=True),
    sa.Column('text', sa.String(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('node_id', sa.Integer(), nullable=True),
    sa.Column('alert_id', sa.Integer(), nullable=True),
    sa.Column('rule_id', sa.Integer(), nullable=True),
    sa.Column('tag_id', sa.Integer(), nullable=True),
    sa.Column('query_id', sa.Integer(), nullable=True),
    sa.Column('pack_id', sa.Integer(), nullable=True),
    sa.Column('config_id', sa.Integer(), nullable=True),
    sa.Column('settings_id', sa.Integer(), nullable=True),
    sa.Column('default_filters_id', sa.Integer(), nullable=True),
    sa.Column('default_query_id', sa.Integer(), nullable=True),
    sa.Column('node_config_id', sa.Integer(), nullable=True),
    sa.Column('threat_intel_credentials_id', sa.Integer(), nullable=True),
    sa.Column('virus_total_av_engines_id', sa.Integer(), nullable=True),
    sa.Column('ioc_intel_id', sa.Integer(), nullable=True),
    sa.Column('carve_session_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['alert_id'], ['alerts.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['node_id'], ['node.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['config_id'], ['config.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['default_filters_id'], ['default_filters.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['default_query_id'], ['default_query.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['ioc_intel_id'], ['ioc_intel.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['carve_session_id'], ['carve_session.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['node_config_id'], ['node_config.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['pack_id'], ['pack.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['query_id'], ['query.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['rule_id'], ['rule.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['settings_id'], ['settings.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['threat_intel_credentials_id'], ['threat_intel_credentials.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['virus_total_av_engines_id'], ['virus_total_av_engines.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )

    op.add_column('distributed_query', sa.Column('owner_id', sa.Integer(), nullable=True))
    op.add_column('distributed_query', sa.Column('owner_permissions', flask_authorize.mixins.PipedList(), nullable=True))
    op.create_foreign_key(None, 'distributed_query', 'user', ['owner_id'], ['id'])

    op.add_column('alerts', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('default_query', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('default_query', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('distributed_query', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('distributed_query', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('groups', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('groups', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('node_config', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('pack', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('pack', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('query', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('query', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('roles', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('roles', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('rule', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('tag', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('tag', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('threat_intel_credentials', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('threat_intel_credentials', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.alter_column('user', 'created_at', existing_type=postgresql.TIMESTAMP(), nullable=True)
    op.add_column('virus_total_av_engines', sa.Column('created_at', sa.DateTime(), nullable=True))
    op.add_column('virus_total_av_engines', sa.Column('updated_at', sa.DateTime(), nullable=True))
    op.add_column('ioc_intel', sa.Column('updated_at', sa.DateTime(), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('ioc_intel', 'updated_at')
    op.drop_column('virus_total_av_engines', 'updated_at')
    op.drop_column('virus_total_av_engines', 'created_at')
    op.alter_column('user', 'created_at', existing_type=postgresql.TIMESTAMP(), nullable=True)
    op.drop_column('threat_intel_credentials', 'updated_at')
    op.drop_column('threat_intel_credentials', 'created_at')
    op.drop_column('tag', 'updated_at')
    op.drop_column('tag', 'created_at')
    op.drop_column('rule', 'created_at')
    op.drop_column('roles', 'updated_at')
    op.drop_column('roles', 'created_at')
    op.drop_column('query', 'updated_at')
    op.drop_column('query', 'created_at')
    op.drop_column('pack', 'updated_at')
    op.drop_column('pack', 'created_at')
    op.drop_column('node_config', 'created_at')
    op.drop_column('groups', 'updated_at')
    op.drop_column('groups', 'created_at')
    op.drop_column('distributed_query', 'updated_at')
    op.drop_column('distributed_query', 'created_at')
    op.drop_column('default_query', 'updated_at')
    op.drop_column('default_query', 'created_at')
    op.drop_column('alerts', 'updated_at')

    op.drop_constraint(None, 'distributed_query', type_='foreignkey')
    op.drop_column('distributed_query', 'owner_permissions')
    op.drop_column('distributed_query', 'owner_id')

    op.drop_table('platform_activity')
    # ### end Alembic commands ###
empty message  Revision ID: <KEY> Revises: <PASSWORD> Create Date: 2021-12-28 21:12:20.185905 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###