From 9e822789d211ab78ae69a7a1d972de8774fd747a Mon Sep 17 00:00:00 2001 From: kolo Date: Fri, 2 Jan 2026 21:54:53 +0300 Subject: [PATCH] Initial commit --- alembic/versions/bec177451434_test_fix.py | 29 +++++++++++++++++++ src/trudex/domain/schemas.py | 1 + .../infrastructure/database/dao/test.py | 5 ++++ .../infrastructure/database/dto/test.py | 1 + src/trudex/infrastructure/database/models.py | 1 + 5 files changed, 37 insertions(+) create mode 100644 alembic/versions/bec177451434_test_fix.py diff --git a/alembic/versions/bec177451434_test_fix.py b/alembic/versions/bec177451434_test_fix.py new file mode 100644 index 0000000..a42ae55 --- /dev/null +++ b/alembic/versions/bec177451434_test_fix.py @@ -0,0 +1,29 @@ +"""test fix + +Revision ID: bec177451434 +Revises: a879badde4a5 +Create Date: 2026-01-02 21:54:33.772279 + +""" +from collections.abc import Sequence + +from alembic import op +import sqlalchemy as sa + + +revision: str = 'bec177451434' +down_revision: str | None = 'a879badde4a5' +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('tests', sa.Column('attempts', sa.Integer(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('tests', 'attempts') + # ### end Alembic commands ### diff --git a/src/trudex/domain/schemas.py b/src/trudex/domain/schemas.py index 40c5949..eb67188 100644 --- a/src/trudex/domain/schemas.py +++ b/src/trudex/domain/schemas.py @@ -31,6 +31,7 @@ class Test: for_group: int | None = None password: str | None = None expires_at: datetime | None = None + attempts: int | None = None is_active: bool = True created_at: datetime | None = None updated_at: datetime | None = None diff --git a/src/trudex/infrastructure/database/dao/test.py b/src/trudex/infrastructure/database/dao/test.py index 7bd0172..505a90c 100644 --- a/src/trudex/infrastructure/database/dao/test.py +++ b/src/trudex/infrastructure/database/dao/test.py @@ -33,6 +33,7 @@ class TestDAO: for_group: int | None = None, password: str | None = None, expires_at: datetime | None = None, + attempts: int | None = None, is_active: bool = True, ) -> DomainTest: test = Test( @@ -41,6 +42,7 @@ class TestDAO: for_group=for_group, password=password, expires_at=expires_at, + attempts=attempts, is_active=is_active, ) self.session.add(test) @@ -56,6 +58,7 @@ class TestDAO: for_group: int | None = None, password: str | None = None, expires_at: datetime | None = None, + attempts: int | None = None, is_active: bool | None = None, ) -> DomainTest | None: result = await self.session.execute( @@ -75,6 +78,8 @@ class TestDAO: test.password = password if expires_at is not None: test.expires_at = expires_at + if attempts is not None: + test.attempts = attempts if is_active is not None: test.is_active = is_active diff --git a/src/trudex/infrastructure/database/dto/test.py b/src/trudex/infrastructure/database/dto/test.py index f3fa61e..0be7a2c 100644 --- a/src/trudex/infrastructure/database/dto/test.py +++ b/src/trudex/infrastructure/database/dto/test.py @@ -14,6 +14,7 @@ class TestDTO: for_group=self.model.for_group, password=self.model.password, expires_at=self.model.expires_at, + attempts=self.model.attempts, is_active=self.model.is_active, created_at=self.model.created_at, updated_at=self.model.updated_at, diff --git a/src/trudex/infrastructure/database/models.py b/src/trudex/infrastructure/database/models.py index 123f9e6..043b135 100644 --- a/src/trudex/infrastructure/database/models.py +++ b/src/trudex/infrastructure/database/models.py @@ -59,6 +59,7 @@ class Test(Base): for_group: Mapped[int | None] = mapped_column(default=None) password: Mapped[str | None] = mapped_column(String(255), default=None) expires_at: Mapped[datetime | None] = mapped_column(default=None) + attempts: Mapped[int | None] = mapped_column(Integer, default=None) is_active: Mapped[bool] = mapped_column(default=True) created_at: Mapped[datetime] = mapped_column(server_default=func.now()) updated_at: Mapped[datetime] = mapped_column(server_default=func.now(), onupdate=func.now())