fix: add missing timestamps to ssh_keys model
SSHKey model was missing created_at/updated_at columns which the API response model expected. Add TimestampMixin and Alembic migration.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""add timestamps to ssh_keys table
|
||||
|
||||
Revision ID: 0005_ssh_keys_timestamps
|
||||
Revises: 0004_tool_types
|
||||
Create Date: 2026-05-19 09:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "0005_ssh_keys_timestamps"
|
||||
down_revision: Union[str, None] = "0004_tool_types"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
"ssh_keys",
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=True,
|
||||
),
|
||||
)
|
||||
op.add_column(
|
||||
"ssh_keys",
|
||||
sa.Column(
|
||||
"updated_at",
|
||||
sa.DateTime(timezone=True),
|
||||
server_default=sa.text("now()"),
|
||||
nullable=True,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column("ssh_keys", "updated_at")
|
||||
op.drop_column("ssh_keys", "created_at")
|
||||
@@ -5,14 +5,14 @@ from sqlalchemy import ForeignKey, String, Text
|
||||
from sqlalchemy import Uuid as UUID
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from src.models.base import Base, UUIDPrimaryKeyMixin
|
||||
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.models.project import Project
|
||||
from src.models.user import User
|
||||
|
||||
|
||||
class SSHKey(UUIDPrimaryKeyMixin, Base):
|
||||
class SSHKey(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
||||
__tablename__ = "ssh_keys"
|
||||
|
||||
name: Mapped[str] = mapped_column(String(255))
|
||||
|
||||
Reference in New Issue
Block a user