From 6f76c74839100e5be3e757b0206d6664824a90d6 Mon Sep 17 00:00:00 2001 From: msm Date: Wed, 30 Oct 2024 22:51:03 +0100 Subject: [PATCH] Add a QueuedFile object --- .../versions/85ed22b90d72_add_queuedfile.py | 35 +++++++++++++++++++ src/models/queuedfile.py | 14 ++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/migrations/versions/85ed22b90d72_add_queuedfile.py create mode 100644 src/models/queuedfile.py diff --git a/src/migrations/versions/85ed22b90d72_add_queuedfile.py b/src/migrations/versions/85ed22b90d72_add_queuedfile.py new file mode 100644 index 00000000..4887e290 --- /dev/null +++ b/src/migrations/versions/85ed22b90d72_add_queuedfile.py @@ -0,0 +1,35 @@ +"""add queuedfile +Revision ID: 85ed22b90d72 +Revises: 6b495d5a4855 +Create Date: 2024-10-27 18:35:05.991934 +""" +from alembic import op +import sqlalchemy as sa +import sqlmodel + + +# revision identifiers, used by Alembic. +revision = "85ed22b90d72" +down_revision = "6b495d5a4855" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table( + "queuedfile", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column( + "ursadb_id", sqlmodel.sql.sqltypes.AutoString(), nullable=False + ), + sa.Column("path", sqlmodel.sql.sqltypes.AutoString(), nullable=False), + sa.PrimaryKeyConstraint("id"), + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table("queuedfile") + # ### end Alembic commands ### diff --git a/src/models/queuedfile.py b/src/models/queuedfile.py new file mode 100644 index 00000000..d89a16c0 --- /dev/null +++ b/src/models/queuedfile.py @@ -0,0 +1,14 @@ +from sqlmodel import SQLModel, Field +from typing import Union + + +class QueuedFile(SQLModel, table=True): + """Represents a file queued to be indexed.""" + + id: Union[int, None] = Field(default=None, primary_key=True) + + # ID of the ursadb ("agent group") this file belongs to. + ursadb_id: str + + # A file path on one of the daemons + path: str