spiff-arena/spiffworkflow-backend/migrations/versions/6aa02463da9c_.py

47 lines
1.7 KiB
Python
Raw Normal View History

"""empty message
Revision ID: 6aa02463da9c
Revises: 68adb1d504e1
Create Date: 2023-05-04 12:50:07.979692
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '6aa02463da9c'
down_revision = '68adb1d504e1'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('active_user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('last_visited_identifier', sa.String(length=255), nullable=False),
sa.Column('last_seen_in_seconds', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('user_id', 'last_visited_identifier', name='user_last_visited_unique')
)
with op.batch_alter_table('active_user', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_active_user_last_seen_in_seconds'), ['last_seen_in_seconds'], unique=False)
batch_op.create_index(batch_op.f('ix_active_user_last_visited_identifier'), ['last_visited_identifier'], unique=False)
batch_op.create_index(batch_op.f('ix_active_user_user_id'), ['user_id'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('active_user', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_active_user_user_id'))
batch_op.drop_index(batch_op.f('ix_active_user_last_visited_identifier'))
batch_op.drop_index(batch_op.f('ix_active_user_last_seen_in_seconds'))
op.drop_table('active_user')
# ### end Alembic commands ###