Skip to content

Commit

Permalink
Merge branch 'main' into fix/add-notification-size-validator
Browse files Browse the repository at this point in the history
  • Loading branch information
whabanks authored Jan 23, 2024
2 parents b788d82 + ee78d28 commit 6ab3a6b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ class ApiKey(BaseModel, Versioned):
created_by = db.relationship("User")
created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey("users.id"), index=True, nullable=False)
compromised_key_info = db.Column(JSONB(none_as_null=True), nullable=True, default={})
last_used_timestamp = db.Column(db.DateTime, index=False, unique=False, nullable=True, default=None)

__table_args__ = (
Index(
Expand Down
22 changes: 22 additions & 0 deletions migrations/versions/0443_add_apikey_last_used_column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Revision ID: 0443_add_apikey_last_used_column
Revises: 0442_add_heartbeat_templates
Create Date: 2022-09-21 00:00:00
"""
from datetime import datetime

import sqlalchemy as sa
from alembic import op

revision = "0443_add_apikey_last_used_column"
down_revision = "0442_add_heartbeat_templates"


def upgrade():
op.add_column("api_keys", sa.Column("last_used_timestamp", sa.DateTime(), nullable=True))
op.add_column("api_keys_history", sa.Column("last_used_timestamp", sa.DateTime(), nullable=True))


def downgrade():
op.drop_column("api_keys", "last_used_timestamp")
op.drop_column("api_keys_history", "last_used_timestamp")
1 change: 1 addition & 0 deletions tests/app/dao/test_api_key_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_save_api_key_should_create_new_api_key_and_history(sample_service):
assert len(all_api_keys) == 1
assert all_api_keys[0] == api_key
assert api_key.version == 1
assert api_key.last_used_timestamp is None

all_history = api_key.get_history_model().query.all()
assert len(all_history) == 1
Expand Down

0 comments on commit 6ab3a6b

Please sign in to comment.