53 lines
2.1 KiB
Python
53 lines
2.1 KiB
Python
"""empty message
|
|
|
|
Revision ID: 9d5b6c5c31a5
|
|
Revises: 55bbdeb6b635
|
|
Create Date: 2023-09-14 08:49:53.619192
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '9d5b6c5c31a5'
|
|
down_revision = '55bbdeb6b635'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('service_account',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=255), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('created_by_user_id', sa.Integer(), nullable=False),
|
|
sa.Column('api_key_hash', sa.String(length=255), nullable=False),
|
|
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
|
|
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['created_by_user_id'], ['user.id'], ),
|
|
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('name', 'created_by_user_id', name='service_account_uniq')
|
|
)
|
|
with op.batch_alter_table('service_account', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_service_account_api_key_hash'), ['api_key_hash'], unique=True)
|
|
batch_op.create_index(batch_op.f('ix_service_account_created_by_user_id'), ['created_by_user_id'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_service_account_name'), ['name'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_service_account_user_id'), ['user_id'], unique=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('service_account', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_service_account_user_id'))
|
|
batch_op.drop_index(batch_op.f('ix_service_account_name'))
|
|
batch_op.drop_index(batch_op.f('ix_service_account_created_by_user_id'))
|
|
batch_op.drop_index(batch_op.f('ix_service_account_api_key_hash'))
|
|
|
|
op.drop_table('service_account')
|
|
# ### end Alembic commands ###
|