53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
"""Add file_signatures table for incremental loading
|
|
|
|
Revision ID: incremental_file_signatures
|
|
Revises: 1d0bb7fede17
|
|
Create Date: 2025-01-27 12:00:00.000000
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
from uuid import uuid4
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "incremental_file_signatures"
|
|
down_revision = "1d0bb7fede17"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"file_signatures",
|
|
sa.Column("id", sa.UUID(), nullable=False, default=uuid4),
|
|
sa.Column("data_id", sa.UUID(), nullable=True),
|
|
sa.Column("file_path", sa.String(), nullable=True),
|
|
sa.Column("file_size", sa.Integer(), nullable=True),
|
|
sa.Column("content_hash", sa.String(), nullable=True),
|
|
sa.Column("total_blocks", sa.Integer(), nullable=True),
|
|
sa.Column("block_size", sa.Integer(), nullable=True),
|
|
sa.Column("strong_len", sa.Integer(), nullable=True),
|
|
sa.Column("signature_data", sa.LargeBinary(), nullable=True),
|
|
sa.Column("blocks_info", sa.JSON(), nullable=True),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_file_signatures_data_id"), "file_signatures", ["data_id"], unique=False
|
|
)
|
|
op.create_index(
|
|
op.f("ix_file_signatures_content_hash"), "file_signatures", ["content_hash"], unique=False
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f("ix_file_signatures_content_hash"), table_name="file_signatures")
|
|
op.drop_index(op.f("ix_file_signatures_data_id"), table_name="file_signatures")
|
|
op.drop_table("file_signatures")
|
|
# ### end Alembic commands ###
|