diff --git a/api/migrations/versions/2024_12_06_1324-5f42bf0de698_add_created_by_to_api_tokens.py b/api/migrations/versions/2024_12_07_1936-8db4e7683504_add_created_by_to_api_tokens.py similarity index 76% rename from api/migrations/versions/2024_12_06_1324-5f42bf0de698_add_created_by_to_api_tokens.py rename to api/migrations/versions/2024_12_07_1936-8db4e7683504_add_created_by_to_api_tokens.py index cc2d77859be4ab..a7c833b8ff2ded 100644 --- a/api/migrations/versions/2024_12_06_1324-5f42bf0de698_add_created_by_to_api_tokens.py +++ b/api/migrations/versions/2024_12_07_1936-8db4e7683504_add_created_by_to_api_tokens.py @@ -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 @@ -11,7 +11,7 @@ # revision identifiers, used by Alembic. -revision = '5f42bf0de698' +revision = '8db4e7683504' down_revision = '01d6889832f7' branch_labels = None depends_on = None @@ -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 ### diff --git a/api/models/model.py b/api/models/model.py index 6f403ab23aa10b..8dfa0dc162a759 100644 --- a/api/models/model.py +++ b/api/models/model.py @@ -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()"))