mirror of
https://github.com/Rarebuffalo/securelens-backend.git
synced 2026-06-19 07:00:30 +00:00
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Add API Key model
|
|
|
|
Revision ID: a8253e561192
|
|
Revises: a2ca840d767c
|
|
Create Date: 2026-03-24 18:31:38.229135
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'a8253e561192'
|
|
down_revision: Union[str, Sequence[str], None] = 'a2ca840d767c'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('api_keys',
|
|
sa.Column('id', sa.String(length=36), nullable=False),
|
|
sa.Column('user_id', sa.String(length=36), nullable=False),
|
|
sa.Column('name', sa.String(length=100), nullable=False),
|
|
sa.Column('key_prefix', sa.String(length=10), nullable=False),
|
|
sa.Column('hashed_key', sa.String(length=255), nullable=False),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_api_keys_hashed_key'), 'api_keys', ['hashed_key'], unique=True)
|
|
op.create_index(op.f('ix_api_keys_user_id'), 'api_keys', ['user_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_api_keys_user_id'), table_name='api_keys')
|
|
op.drop_index(op.f('ix_api_keys_hashed_key'), table_name='api_keys')
|
|
op.drop_table('api_keys')
|
|
# ### end Alembic commands ###
|