-
Notifications
You must be signed in to change notification settings - Fork 40
eat: add ManualVerification model and migration for manual control verification #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
backend-api/alembic/versions/a9befc7a716c_add_manual_verification_table.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| """Add manual_verification table | ||
|
|
||
| Revision ID: a9befc7a716c | ||
| Revises: j2k3l4m5n678 | ||
| Create Date: 2026-04-04 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "a9befc7a716c" | ||
| down_revision: Union[str, Sequence[str], None] = "j1k2l3m4n567" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| op.create_table( | ||
| "manual_verification", | ||
| sa.Column("id", sa.Integer(), nullable=False), | ||
| sa.Column("scan_id", sa.Integer(), nullable=False), | ||
| sa.Column("control_id", sa.String(length=50), nullable=False), | ||
| sa.Column("user_id", sa.Integer(), nullable=False), | ||
| sa.Column("status", sa.String(length=20), nullable=False), | ||
| sa.Column("comment", sa.Text(), nullable=True), | ||
| sa.Column( | ||
| "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False | ||
| ), | ||
| sa.Column( | ||
| "updated_at", | ||
| sa.DateTime(), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.ForeignKeyConstraint(["scan_id"], ["scan.id"], ondelete="CASCADE"), | ||
| sa.ForeignKeyConstraint(["user_id"], ["user.id"], ondelete="CASCADE"), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| ) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| op.drop_table("manual_verification") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| """manualVerification Model for user-submitted control verifications.""" | ||
|
|
||
| from datetime import datetime | ||
| from typing import TYPE_CHECKING, Optional | ||
|
|
||
| from sqlalchemy import ForeignKey, String, Text | ||
| from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
| from sqlalchemy.sql import func | ||
|
|
||
| from app.db.base import Base | ||
|
|
||
| if TYPE_CHECKING: | ||
| from app.models.compliance import Scan # prevent version conflict with circular import | ||
| from app.models.user import User # prevent version conflict with circular import | ||
|
|
||
| class ManualVerification(Base): | ||
| """Model for manual verification of controls by users.""" | ||
|
|
||
| __tablename__ = "manual_verification" | ||
|
|
||
| id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) | ||
| scan_id: Mapped[int] = mapped_column(ForeignKey("scan.id"), nullable=False) | ||
| control_id: Mapped[str] = mapped_column(String(50), nullable=False) | ||
| user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), nullable=False) | ||
| # Status: passed or failed | ||
| status: Mapped[str] = mapped_column(String(20), nullable=False) | ||
| comment: Mapped[Optional[str]] = mapped_column(Text, nullable=True) | ||
|
|
||
| created_at: Mapped[datetime] = mapped_column(server_default=func.now(), nullable=False) | ||
| updated_at: Mapped[datetime] = mapped_column(server_default=func.now(), onupdate=func.now(), nullable=False) | ||
|
|
||
| # Relationships | ||
| scan: Mapped["Scan"] = relationship() | ||
| user: Mapped["User"] = relationship() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.