Add name to API Key (#1327)

This commit is contained in:
Alan Hagedorn 2024-04-13 12:36:46 -07:00 committed by GitHub
parent d2d042a2cc
commit b9b1e22fac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,23 @@
"""Add name to api_key
Revision ID: 475fcefe8826
Revises: ecab2b3f1a3b
Create Date: 2024-04-11 11:05:18.414438
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "475fcefe8826"
down_revision = "ecab2b3f1a3b"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column("api_key", sa.Column("name", sa.String(), nullable=True))
def downgrade() -> None:
op.drop_column("api_key", "name")

View File

@ -87,6 +87,7 @@ class ApiKey(Base):
__tablename__ = "api_key"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str | None] = mapped_column(String, nullable=True)
hashed_api_key: Mapped[str] = mapped_column(String, unique=True)
api_key_display: Mapped[str] = mapped_column(String, unique=True)
# the ID of the "user" who represents the access credentials for the API key