Skip to content
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

Add a QueuedFile object #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/migrations/versions/85ed22b90d72_add_queuedfile.py
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add something like "indexed" column so we know which files are already indexed?
It would easier the workflow and allow to delete indexed files easily.

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 ###
14 changes: 14 additions & 0 deletions src/models/queuedfile.py
Original file line number Diff line number Diff line change
@@ -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
Loading