Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: Backfill file processing status (#2680)

Matthew Zhou64297643fd8f
diff --git a/alembic/versions/9792f94e961d_add_file_processing_status_to_.py b/alembic/versions/9792f94e961d_add_file_processing_status_to_.py
index f259da662..340e7990b 100644
--- a/alembic/versions/9792f94e961d_add_file_processing_status_to_.py
+++ b/alembic/versions/9792f94e961d_add_file_processing_status_to_.py
@@ -20,14 +20,23 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
- # ### commands auto generated by Alembic - please adjust! ###
+ # Step 1: Create constraint
op.create_unique_constraint("uq_file_contents_file_id", "file_contents", ["file_id"])
- op.add_column("files", sa.Column("processing_status", sa.String(), nullable=False))
+
+ # Step 2: Add processing_status as nullable first
+ op.add_column("files", sa.Column("processing_status", sa.String(), nullable=True))
op.add_column("files", sa.Column("error_message", sa.Text(), nullable=True))
+
+ # Step 3: Backfill existing rows with 'completed'
+ op.execute("UPDATE files SET processing_status = 'completed'")
+
+ # Step 4: Make the column non-nullable now that it's backfilled
+ op.alter_column("files", "processing_status", nullable=False)
+
+ # Step 5: Create indices
op.create_index("ix_files_org_created", "files", ["organization_id", sa.literal_column("created_at DESC")], unique=False)
op.create_index("ix_files_processing_status", "files", ["processing_status"], unique=False)
op.create_index("ix_files_source_created", "files", ["source_id", sa.literal_column("created_at DESC")], unique=False)
- # ### end Alembic commands ###
def downgrade() -> None: