Skip to content

Commit

Permalink
chore: add created_by index to api_tokens table
Browse files Browse the repository at this point in the history
  • Loading branch information
hgbdev committed Dec 7, 2024
1 parent c9c9ca7 commit 4a1777c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""add created_by to api_tokens
Revision ID: 5f42bf0de698
Revision ID: 8db4e7683504
Revises: 01d6889832f7
Create Date: 2024-12-06 13:24:28.701384
Create Date: 2024-12-07 19:36:49.632151
"""
from alembic import op
Expand All @@ -11,7 +11,7 @@


# revision identifiers, used by Alembic.
revision = '5f42bf0de698'
revision = '8db4e7683504'
down_revision = '01d6889832f7'
branch_labels = None
depends_on = None
Expand All @@ -21,11 +21,15 @@ def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('api_tokens', schema=None) as batch_op:
batch_op.add_column(sa.Column('created_by', models.types.StringUUID(), nullable=True))
batch_op.create_index('api_token_created_by_idx', ['created_by'], unique=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('api_tokens', schema=None) as batch_op:
batch_op.drop_index('api_token_created_by_idx')
batch_op.drop_column('created_by')

# ### end Alembic commands ###
1 change: 1 addition & 0 deletions api/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,7 @@ class ApiToken(db.Model):
db.Index("api_token_app_id_type_idx", "app_id", "type"),
db.Index("api_token_token_idx", "token", "type"),
db.Index("api_token_tenant_idx", "tenant_id", "type"),
db.Index("api_token_created_by_idx", "created_by"),
)

id = db.Column(StringUUID, server_default=db.text("uuid_generate_v4()"))
Expand Down

0 comments on commit 4a1777c

Please sign in to comment.