chore(logging): enforce ruff G004, convert f-strings to %-style (#10767)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
WenxiandClaude Opus 4.6 authored and GitHub committed 2026-05-01 23:31:52 +00:00
1 parent 1223e610b8
commit ca216abe71
544 files changed
+4960 -3240

No files matched your search

+27 -13
View File
@@ -161,7 +161,7 @@ def get_schema_options() -> (
name.strip() for name in schema_names_str.split(",") if name.strip()
]
if schemas:
logger.info(f"Specific schema names specified: {schemas}")
logger.info("Specific schema names specified: %s", schemas)
# Validate that only one method is used at a time
range_filtering = tenant_range_start is not None or tenant_range_end is not None
@@ -282,14 +282,17 @@ async def run_async_migrations() -> None:
if schemas:
# Use specific schema names directly without fetching all tenants
logger.info(f"Migrating specific schema names: {schemas}")
logger.info("Migrating specific schema names: %s", schemas)
i_schema = 0
num_schemas = len(schemas)
for schema in schemas:
i_schema += 1
logger.info(
f"Migrating schema: index={i_schema} num_schemas={num_schemas} schema={schema}"
"Migrating schema: index=%s num_schemas=%s schema=%s",
i_schema,
num_schemas,
schema,
)
try:
async with engine.connect() as connection:
@@ -300,7 +303,7 @@ async def run_async_migrations() -> None:
)
await connection.commit()
except Exception as e:
logger.error(f"Error migrating schema {schema}: {e}")
logger.error("Error migrating schema %s: %s", schema, e)
if not continue_on_error:
logger.error("--continue=true is not set, raising exception!")
raise
@@ -316,10 +319,14 @@ async def run_async_migrations() -> None:
if tenant_range_start is not None or tenant_range_end is not None:
logger.info(
f"Filtering tenants by range: start={tenant_range_start}, end={tenant_range_end}"
"Filtering tenants by range: start=%s, end=%s",
tenant_range_start,
tenant_range_end,
)
logger.info(
f"Total tenants: {len(tenant_schemas)}, Filtered tenants: {len(filtered_tenant_schemas)}"
"Total tenants: %s, Filtered tenants: %s",
len(tenant_schemas),
len(filtered_tenant_schemas),
)
i_tenant = 0
@@ -327,7 +334,10 @@ async def run_async_migrations() -> None:
for schema in filtered_tenant_schemas:
i_tenant += 1
logger.info(
f"Migrating schema: index={i_tenant} num_tenants={num_tenants} schema={schema}"
"Migrating schema: index=%s num_tenants=%s schema=%s",
i_tenant,
num_tenants,
schema,
)
try:
async with engine.connect() as connection:
@@ -338,7 +348,7 @@ async def run_async_migrations() -> None:
)
await connection.commit()
except Exception as e:
logger.error(f"Error migrating schema {schema}: {e}")
logger.error("Error migrating schema %s: %s", schema, e)
if not continue_on_error:
logger.error("--continue=true is not set, raising exception!")
raise
@@ -384,10 +394,10 @@ def run_migrations_offline() -> None:
if schemas:
# Use specific schema names directly without fetching all tenants
logger.info(f"Migrating specific schema names: {schemas}")
logger.info("Migrating specific schema names: %s", schemas)
for schema in schemas:
logger.info(f"Migrating schema: {schema}")
logger.info("Migrating schema: %s", schema)
context.configure(
url=url,
target_metadata=target_metadata,
@@ -421,14 +431,18 @@ def run_migrations_offline() -> None:
if tenant_range_start is not None or tenant_range_end is not None:
logger.info(
f"Filtering tenants by range: start={tenant_range_start}, end={tenant_range_end}"
"Filtering tenants by range: start=%s, end=%s",
tenant_range_start,
tenant_range_end,
)
logger.info(
f"Total tenants: {len(tenant_schemas)}, Filtered tenants: {len(filtered_tenant_schemas)}"
"Total tenants: %s, Filtered tenants: %s",
len(tenant_schemas),
len(filtered_tenant_schemas),
)
for schema in filtered_tenant_schemas:
logger.info(f"Migrating schema: {schema}")
logger.info("Migrating schema: %s", schema)
context.configure(
url=url,
target_metadata=target_metadata,
@@ -32,7 +32,6 @@ from onyx.db.engine.tenant_utils import get_all_tenant_ids
from onyx.db.engine.tenant_utils import get_schemas_needing_migration
from shared_configs.configs import TENANT_ID_PREFIX
# ---------------------------------------------------------------------------
# Data types
# ---------------------------------------------------------------------------
@@ -8,7 +8,6 @@ Create Date: 2026-01-31 17:37:10.485558
from alembic import op
# revision identifiers, used by Alembic.
revision = "01f8e6d95a33"
down_revision = "d5c86e2c6dc6"
@@ -9,7 +9,6 @@ Create Date: 2025-01-14 12:14:00.814390
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "027381bce97c"
down_revision = "6fc7886d665d"
@@ -16,7 +16,6 @@ from sqlalchemy import text
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "03bf8be6b53a"
down_revision = "65bc6e0f8500"
@@ -9,7 +9,6 @@ Create Date: 2026-03-25 16:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "03d085c5c38d"
down_revision = "977e834c1427"
@@ -9,7 +9,6 @@ Create Date: 2025-09-11 13:30:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "03d710ccf29c" # Generate a new unique ID
down_revision = "96a5702df6aa"
@@ -9,7 +9,6 @@ Create Date: 2026-02-23 15:55:07.606784
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "07b98176f1de"
down_revision = "7cb492013621"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "0816326d83aa"
down_revision = "12635f6655b7"
@@ -9,7 +9,6 @@ Create Date: 2024-07-23 11:12:39.462397
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "08a1eda20fe1"
down_revision = "8a87bd6ec550"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from onyx.db.enums import ThemePreference
# revision identifiers, used by Alembic.
revision = "09995b8811eb"
down_revision = "3d1cca026fe8"
@@ -9,7 +9,6 @@ Create Date: 2026-02-20 10:45:30.340188
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0bb4558f35df"
down_revision = "631fd2504136"
@@ -41,7 +41,7 @@ def upgrade() -> None:
).scalar_one()
if null_count > 0:
logger.info(f"Generating UUIDs for {null_count} user_file records...")
logger.info("Generating UUIDs for %s user_file records...", null_count)
# Populate in batches to avoid long locks
batch_size = 10000
@@ -70,9 +70,9 @@ def upgrade() -> None:
if updated < batch_size:
break
logger.info(f" Updated {total_updated}/{null_count} records...")
logger.info(" Updated %s/%s records...", total_updated, null_count)
logger.info(f"Generated UUIDs for {total_updated} user_file records")
logger.info("Generated UUIDs for %s user_file records", total_updated)
# Verify all records have UUIDs
remaining_null = bind.execute(
@@ -108,7 +108,7 @@ def upgrade() -> None:
).scalar_one()
if null_count > 0:
logger.info(f"Updating {null_count} persona__user_file records...")
logger.info("Updating %s persona__user_file records...", null_count)
# Update in batches
batch_size = 10000
@@ -140,9 +140,9 @@ def upgrade() -> None:
if updated < batch_size:
break
logger.info(f" Updated {total_updated}/{null_count} records...")
logger.info(" Updated %s/%s records...", total_updated, null_count)
logger.info(f"Updated {total_updated} persona__user_file records")
logger.info("Updated %s persona__user_file records", total_updated)
# Verify all records are populated
remaining_null = bind.execute(
@@ -181,7 +181,7 @@ def upgrade() -> None:
)
)
logger.info(f"Created {result.rowcount} user_project records from chat_folder")
logger.info("Created %s user_project records from chat_folder", result.rowcount)
# === Step 4: Populate chat_session.project_id ===
chat_session_columns = [
@@ -202,7 +202,7 @@ def upgrade() -> None:
).scalar_one()
if null_count > 0:
logger.info(f"Updating {null_count} chat_session records...")
logger.info("Updating %s chat_session records...", null_count)
result = bind.execute(
text(
@@ -216,7 +216,7 @@ def upgrade() -> None:
)
)
logger.info(f"Updated {result.rowcount} chat_session records")
logger.info("Updated %s chat_session records", result.rowcount)
# Verify all records are populated
remaining_null = bind.execute(
@@ -230,7 +230,8 @@ def upgrade() -> None:
if remaining_null > 0:
logger.warning(
f"Warning: {remaining_null} chat_session records could not be mapped to projects"
"Warning: %s chat_session records could not be mapped to projects",
remaining_null,
)
# === Step 5: Update plaintext FileRecord IDs/display names to UUID scheme ===
@@ -251,7 +252,7 @@ def upgrade() -> None:
legacy_count = bind.execute(count_query).scalar_one()
if legacy_count and legacy_count > 0:
logger.info(f"Found {legacy_count} legacy plaintext file records to update")
logger.info("Found %s legacy plaintext file records to update", legacy_count)
# Update display_name first for readability (safe regardless of rename)
bind.execute(
@@ -281,7 +282,7 @@ def upgrade() -> None:
)
)
logger.info(
f"Updated {result.rowcount} plaintext file_record ids to UUID scheme"
"Updated %s plaintext file_record ids to UUID scheme", result.rowcount
)
# === Step 6: Ensure document_id_migrated default TRUE and backfill existing FALSE ===
@@ -338,7 +339,7 @@ def upgrade() -> None:
)
)
logger.info(f"Updated status for {result.rowcount} user_file records")
logger.info("Updated status for %s user_file records", result.rowcount)
logger.info("Migration 2 (data preparation) completed successfully")
@@ -9,7 +9,6 @@ Create Date: 2024-09-10 15:03:48.233926
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "0ebb1d516877"
down_revision = "52a219fb5233"
@@ -9,7 +9,6 @@ Create Date: 2026-02-09 18:57:08.274640
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "114a638452db"
down_revision = "feead2911109"
@@ -155,7 +155,7 @@ def update_document_id_in_database(
# print(f"Successfully updated database tables for document {old_doc_id} -> {new_doc_id}")
except Exception as e:
# If the full INSERT fails, try a more basic version with only core columns
logger.warning(f"Full INSERT failed, trying basic version: {e}")
logger.warning("Full INSERT failed, trying basic version: %s", e)
bind.execute(
sa.text(
"""
@@ -273,7 +273,7 @@ def update_document_id_in_database(
)
# print(f"Successfully updated chunk_stats ID field for document {old_doc_id} -> {new_doc_id}")
except Exception as e:
logger.warning(f"Some KG/chunk tables may not exist or failed to update: {e}")
logger.warning("Some KG/chunk tables may not exist or failed to update: %s", e)
# Step 3: Delete the old document row (this should now be safe since all FKs point to new row)
bind.execute(
@@ -498,7 +498,7 @@ def delete_document_from_db(current_doc_id: str, index_name: str) -> None:
except Exception as e:
logger.warning(
f"Some KG/chunk tables may not exist or failed to delete from: {e}"
"Some KG/chunk tables may not exist or failed to delete from: %s", e
)
# Finally delete the document itself
@@ -581,7 +581,7 @@ def upgrade() -> None:
# Continue with other documents instead of failing the entire migration
continue
logger.info(f"Migration complete. Updated {updated_count} Google Drive documents")
logger.info("Migration complete. Updated %s Google Drive documents", updated_count)
def downgrade() -> None:
@@ -60,7 +60,7 @@ def upgrade() -> None:
to_migrate = bind.execute(count_query).scalar_one()
if to_migrate > 0:
logger.info(f"Creating {to_migrate} persona-file relationships...")
logger.info("Creating %s persona-file relationships...", to_migrate)
# Migrate in batches to avoid memory issues
batch_size = 10000
@@ -94,11 +94,11 @@ def upgrade() -> None:
break
logger.info(
f" Migrated {total_inserted}/{to_migrate} relationships..."
" Migrated %s/%s relationships...", total_inserted, to_migrate
)
logger.info(
f"Created {total_inserted} persona__user_file relationships"
"Created %s persona__user_file relationships", total_inserted
)
# === Step 2: Add foreign key for chat_session.project_id ===
@@ -142,7 +142,7 @@ def upgrade() -> None:
to_create = bind.execute(count_query).scalar_one()
if to_create > 0:
logger.info(f"Creating {to_create} project-file relationships...")
logger.info("Creating %s project-file relationships...", to_create)
# Insert in batches
batch_size = 10000
@@ -175,9 +175,11 @@ def upgrade() -> None:
if inserted < batch_size:
break
logger.info(f" Created {total_inserted}/{to_create} relationships...")
logger.info(
" Created %s/%s relationships...", total_inserted, to_create
)
logger.info(f"Created {total_inserted} project__user_file relationships")
logger.info("Created %s project__user_file relationships", total_inserted)
# === Step 4: Create index on chat_session.project_id ===
try:
@@ -229,7 +231,7 @@ def downgrade() -> None:
# Clear project__user_file relationships (but keep the table for migration 1 to handle)
if "project__user_file" in inspector.get_table_names():
result = bind.execute(text("DELETE FROM project__user_file"))
logger.info(f"Cleared {result.rowcount} records from project__user_file")
logger.info("Cleared %s records from project__user_file", result.rowcount)
# Remove migrated persona__user_file relationships
# Only remove those that came from folder relationships
@@ -255,7 +257,7 @@ def downgrade() -> None:
)
)
logger.info(
f"Removed {result.rowcount} migrated persona__user_file relationships"
"Removed %s migrated persona__user_file relationships", result.rowcount
)
logger.info("Downgrade completed successfully")
@@ -9,7 +9,6 @@ Create Date: 2026-02-12 11:21:41.798037
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "19c0ccb01687"
down_revision = "9c54986124c6"
@@ -8,7 +8,6 @@ Create Date: 2024-09-18 11:48:59.418726
from alembic import op
# revision identifiers, used by Alembic.
revision = "1b8206b29c5d"
down_revision = "35e6853a51d5"
@@ -9,7 +9,6 @@ Create Date: 2026-03-26 11:30:53.883127
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "1d78c0ca7853"
down_revision = "a3f8b2c1d4e5"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "1f2a3b4c5d6e"
down_revision = "9drpiiw74ljy"
@@ -22,7 +22,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "2020d417ec84"
down_revision = "41fa44bef321"
@@ -8,7 +8,6 @@ Create Date: 2025-05-19 17:15:33.424584
from alembic import op
# revision identifiers, used by Alembic.
revision = "238b84885828"
down_revision = "a7688ab35c45"
@@ -14,7 +14,6 @@ from onyx.db.enums import AccountType
from onyx.db.enums import GrantSource
from onyx.db.enums import Permission
# revision identifiers, used by Alembic.
revision = "25a5501dc766"
down_revision = "b728689f45b1"
@@ -10,7 +10,6 @@ import fastapi_users_db_sqlalchemy
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "2666d766cb9b"
down_revision = "6d387b3196c2"
@@ -9,7 +9,6 @@ Create Date: 2026-03-08 17:18:40.828644
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "27fb147a843f"
down_revision = "b5c4d7e8f9a1"
@@ -9,7 +9,6 @@ Create Date: 2025-01-04 11:39:43.268612
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "2955778aa44c"
down_revision = "c0aab6edb6dd"
@@ -11,7 +11,6 @@ import sqlalchemy as sa
from onyx.db.enums import SwitchoverType
# revision identifiers, used by Alembic.
revision = "2acdef638fc2"
down_revision = "a4f23d6b71c8"
@@ -50,7 +50,8 @@ def upgrade() -> None:
if orphaned_count > 0:
logger.warning(
f"WARNING: {orphaned_count} chat_session records still have folder_id without project_id. Proceeding anyway."
"WARNING: %s chat_session records still have folder_id without project_id. Proceeding anyway.",
orphaned_count,
)
# === Step 2: Drop chat_session.folder_id ===
@@ -80,7 +81,7 @@ def upgrade() -> None:
if remaining > 0:
logger.warning(
f"WARNING: Dropping persona__user_folder with {remaining} records"
"WARNING: Dropping persona__user_folder with %s records", remaining
)
op.drop_table("persona__user_folder")
@@ -94,7 +95,7 @@ def upgrade() -> None:
remaining = bind.execute(text("SELECT COUNT(*) FROM chat_folder")).scalar_one()
if remaining > 0:
logger.warning(f"WARNING: Dropping chat_folder with {remaining} records")
logger.warning("WARNING: Dropping chat_folder with %s records", remaining)
op.drop_table("chat_folder")
logger.info("Dropped chat_folder table")
@@ -9,7 +9,6 @@ Create Date: 2026-01-03 16:55:30.449692
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "2b90f3af54b8"
down_revision = "9a0296d7421e"
@@ -8,7 +8,6 @@ Create Date: 2026-01-20 16:01:54.314805
from alembic import op
# revision identifiers, used by Alembic.
revision = "2c2430828bdf"
down_revision = "fb80bdd256de"
@@ -8,7 +8,6 @@ Create Date: 2025-02-11 14:57:51.308775
from alembic import op
# revision identifiers, used by Alembic.
revision = "2cdeff6d8c93"
down_revision = "f5437cc136c5"
@@ -9,7 +9,6 @@ Create Date: 2025-01-31 10:30:27.289646
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "2f80c6a2550f"
down_revision = "33ea50e88f24"
@@ -9,7 +9,6 @@ Create Date: 2025-07-10 16:17:57.762182
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "2f95e36923e6"
down_revision = "0816326d83aa"
@@ -11,7 +11,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "31bd8c17325e"
down_revision = "14162713706c"
@@ -9,7 +9,6 @@ Create Date: 2024-11-01 12:51:01.535003
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "33cb72ea4d80"
down_revision = "5b29123cd710"
@@ -8,7 +8,6 @@ Create Date: 2025-01-29 10:54:22.141765
from alembic import op
# revision identifiers, used by Alembic.
revision = "33ea50e88f24"
down_revision = "a6df6b88ef81"
@@ -8,7 +8,6 @@ Create Date: 2024-09-20 21:24:04.891018
from alembic import op
# revision identifiers, used by Alembic.
revision = "35e518e0ddf4"
down_revision = "91a0a4d62b14"
@@ -40,7 +40,7 @@ def upgrade() -> None:
for connector_id, config in github_connectors:
try:
if not config:
logger.warning(f"Connector {connector_id} has no config, skipping")
logger.warning("Connector %s has no config, skipping", connector_id)
continue
# Parse the config if it's a string
@@ -68,7 +68,7 @@ def upgrade() -> None:
)
updated_count += 1
except Exception as e:
logger.error(f"Error updating connector {connector_id}: {str(e)}")
logger.error("Error updating connector %s: %s", connector_id, str(e))
def downgrade() -> None:
@@ -89,7 +89,7 @@ def downgrade() -> None:
)
).fetchall()
logger.debug(f"Found {len(github_connectors)} GitHub connectors to rollback")
logger.debug("Found %s GitHub connectors to rollback", len(github_connectors))
# Revert each GitHub connector to use repo_name instead of repositories
reverted_count = 0
@@ -123,4 +123,4 @@ def downgrade() -> None:
)
reverted_count += 1
except Exception as e:
logger.error(f"Error reverting connector {connector_id}: {str(e)}")
logger.error("Error reverting connector %s: %s", connector_id, str(e))
@@ -9,7 +9,6 @@ Create Date: 2024-06-05 11:18:49.966333
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "3a7802814195"
down_revision = "23957775e5f5"
@@ -39,7 +39,7 @@ def batch_delete(
return 0
logger.info(
f"Starting batch deletion of {total_count} records from {table_name}..."
"Starting batch deletion of %s records from %s...", total_count, table_name
)
# Determine appropriate ARRAY type
@@ -66,16 +66,23 @@ def batch_delete(
batch_num = (i // batch_size) + 1
if batch_num % 10 == 0 or i + batch_size >= total_count:
logger.info(
f" Deleted {min(i + batch_size, total_count)}/{total_count} records "
f"({total_deleted} actual) from {table_name}"
" Deleted %s/%s records (%s actual) from %s",
min(i + batch_size, total_count),
total_count,
total_deleted,
table_name,
)
except Exception as e:
logger.error(f"Failed to delete batch {(i // batch_size) + 1}: {e}")
logger.error("Failed to delete batch %s: %s", i // batch_size + 1, e)
failed_batches.append((i, min(i + batch_size, total_count)))
if failed_batches:
logger.warning(
f"Failed to delete {len(failed_batches)} batches from {table_name}. Total deleted: {total_deleted}/{total_count}"
"Failed to delete %s batches from %s. Total deleted: %s/%s",
len(failed_batches),
table_name,
total_deleted,
total_count,
)
# Fail the migration to avoid silently succeeding on partial cleanup
raise RuntimeError(
@@ -115,7 +122,7 @@ def upgrade() -> None:
doc_ids = [r[0] for r in doc_rows]
if doc_ids:
logger.info(f"Found {len(doc_ids)} user-file documents to delete")
logger.info("Found %s user-file documents to delete", len(doc_ids))
# Delete dependent rows first
tables_to_clean = [
@@ -130,17 +137,17 @@ def upgrade() -> None:
deleted = batch_delete(
bind, table_name, column_name, doc_ids, id_type="str"
)
logger.info(f"Deleted {deleted} records from {table_name}")
logger.info("Deleted %s records from %s", deleted, table_name)
# Delete document_by_connector_credential_pair entries
deleted = batch_delete(
bind, "document_by_connector_credential_pair", "id", doc_ids, id_type="str"
)
logger.info(f"Deleted {deleted} document_by_connector_credential_pair records")
logger.info("Deleted %s document_by_connector_credential_pair records", deleted)
# Delete documents themselves
deleted = batch_delete(bind, "document", "id", doc_ids, id_type="str")
logger.info(f"Deleted {deleted} document records")
logger.info("Deleted %s document records", deleted)
else:
logger.info("No user-file documents found to delete")
@@ -162,7 +169,8 @@ def upgrade() -> None:
if cc_pair_ids:
logger.info(
f"Found {len(cc_pair_ids)} user-file connector_credential_pairs to clean up"
"Found %s user-file connector_credential_pairs to clean up",
len(cc_pair_ids),
)
# Delete related records
@@ -181,7 +189,7 @@ def upgrade() -> None:
deleted = batch_delete(
bind, table_name, column_name, cc_pair_ids, id_type="int"
)
logger.info(f"Deleted {deleted} records from {table_name}")
logger.info("Deleted %s records from %s", deleted, table_name)
# === Step 3: Identify connectors and credentials to delete ===
logger.info("Identifying orphaned connectors and credentials...")
@@ -255,14 +263,14 @@ def upgrade() -> None:
deleted = batch_delete(
bind, "connector_credential_pair", "id", cc_pair_ids, id_type="int"
)
logger.info(f"Deleted {deleted} connector_credential_pair records")
logger.info("Deleted %s connector_credential_pair records", deleted)
# === Step 5: Delete orphaned connectors ===
if userfile_only_connector_ids:
deleted = batch_delete(
bind, "connector", "id", userfile_only_connector_ids, id_type="int"
)
logger.info(f"Deleted {deleted} orphaned connector records")
logger.info("Deleted %s orphaned connector records", deleted)
# === Step 6: Delete orphaned credentials ===
if userfile_only_credential_ids:
@@ -274,13 +282,13 @@ def upgrade() -> None:
userfile_only_credential_ids,
id_type="int",
)
logger.info(f"Deleted {deleted} credential__user_group records")
logger.info("Deleted %s credential__user_group records", deleted)
# Delete credentials
deleted = batch_delete(
bind, "credential", "id", userfile_only_credential_ids, id_type="int"
)
logger.info(f"Deleted {deleted} orphaned credential records")
logger.info("Deleted %s orphaned credential records", deleted)
logger.info("Migration 5 (legacy data cleanup) completed successfully")
@@ -8,7 +8,6 @@ Create Date: 2025-02-26 13:07:56.217791
from alembic import op
# revision identifiers, used by Alembic.
revision = "3bd4c84fe72f"
down_revision = "8f43500ee275"
@@ -9,7 +9,6 @@ Create Date: 2023-06-14 23:45:51.760440
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "3c5e35aa9af0"
down_revision = "27c6ecc08586"
@@ -9,7 +9,6 @@ Create Date: 2023-07-18 17:33:40.365034
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "465f78d9b7f9"
down_revision = "3c5e35aa9af0"
@@ -9,7 +9,6 @@ Create Date: 2025-04-02 11:26:36.180328
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "4794bc13e484"
down_revision = "f7505c5b0284"
@@ -16,7 +16,6 @@ from onyx.llm.well_known_providers.llm_provider_options import (
fetch_visible_model_names_for_provider_as_set,
)
# revision identifiers, used by Alembic.
revision = "47a07e1a38f1"
down_revision = "7a70b7664e37"
@@ -9,7 +9,6 @@ Create Date: 2024-11-05 18:55:02.221064
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "47e5bef3a1d7"
down_revision = "dfbe9e93d3c7"
@@ -17,7 +17,6 @@ from onyx.configs.app_configs import DB_READONLY_PASSWORD
from shared_configs.configs import MULTI_TENANT
from shared_configs.configs import POSTGRES_DEFAULT_SCHEMA
# revision identifiers, used by Alembic.
revision = "495cb26ce93e"
down_revision = "ca04500b9ee8"
@@ -12,7 +12,6 @@ from alembic import op
from sqlalchemy.exc import IntegrityError
from sqlalchemy.sql import text
# revision identifiers, used by Alembic.
revision = "4d58345da04a"
down_revision = "f1ca58b2f2ec"
@@ -51,7 +50,10 @@ def upgrade() -> None:
next_email = f"{username.lower()}_{attempt}@{domain.lower()}"
# Email conflict occurred, append `_1`, `_2`, etc., to the username
logger.warning(
f"Conflict while lowercasing email: old_email={email} conflicting_email={new_email} next_email={next_email}"
"Conflict while lowercasing email: old_email=%s conflicting_email=%s next_email=%s",
email,
new_email,
next_email,
)
new_email = next_email
attempt += 1
@@ -9,7 +9,6 @@ Create Date: 2025-11-24 12:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "4f8a2b3c1d9e"
down_revision = "a852cbe15577"
@@ -20,7 +20,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "503883791c39"
down_revision = "b4b7e1028dfd"
@@ -14,7 +14,6 @@ from uuid import UUID
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "505c488f6662"
down_revision = "d09fc20a3c66"
@@ -8,7 +8,6 @@ Create Date: 2024-12-11 18:05:05.490737
from alembic import op
# revision identifiers, used by Alembic.
revision = "54a74a0417fc"
down_revision = "94dc3d0236f8"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "55546a7967ee"
down_revision = "61ff3651add4"
@@ -9,7 +9,6 @@ Create Date: 2026-02-27 10:10:40.124925
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "57122d037335"
down_revision = "c0c937d5c9e5"
@@ -10,7 +10,6 @@ import fastapi_users_db_sqlalchemy
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5809c0787398"
down_revision = "d929f0c1c6af"
@@ -9,7 +9,6 @@ Create Date: 2025-06-25 14:08:14.162380
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "58c50ef19f08"
down_revision = "7b9b952abdf6"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "5ae8240accb3"
down_revision = "b558f51620b4"
@@ -9,7 +9,6 @@ Create Date: 2024-10-30 19:37:59.630704
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5b29123cd710"
down_revision = "949b4a92a401"
@@ -9,7 +9,6 @@ Create Date: 2026-01-06 16:03:11.413724
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5c3dca366b35"
down_revision = "9087b548dd69"
@@ -9,7 +9,6 @@ Create Date: 2024-10-08 15:56:07.975636
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5d12a446f5c0"
down_revision = "e4334d5b33ba"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "5e1c073d48a3"
down_revision = "09995b8811eb"
@@ -9,7 +9,6 @@ Create Date: 2025-11-30 12:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5e6f7a8b9c0d"
down_revision = "4f8a2b3c1d9e"
@@ -9,7 +9,6 @@ Create Date: 2023-08-10 21:43:09.069523
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "5e84129c8be3"
down_revision = "e6a4bbc13fe4"
@@ -12,7 +12,6 @@ import json
import os
import logging
# revision identifiers, used by Alembic.
revision = "62c3a055a141"
down_revision = "3fc5d75723b3"
@@ -9,7 +9,6 @@ Create Date: 2026-02-18 21:07:52.831215
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "631fd2504136"
down_revision = "c7f2e1b4a9d3"
@@ -9,7 +9,6 @@ Create Date: 2025-09-28 15:48:12.003612
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "64bd5677aeb6"
down_revision = "b30353be4eec"
@@ -9,7 +9,6 @@ Create Date: 2025-06-13 10:04:27.705976
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "65bc6e0f8500"
down_revision = "cec7ec36c505"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID as PGUUID
# revision identifiers, used by Alembic.
revision = "689433b0d8de"
down_revision = "93a2e195e25c"
@@ -9,7 +9,6 @@ Create Date: 2025-12-30 10:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "699221885109"
down_revision = "7e490836d179"
@@ -9,7 +9,6 @@ Create Date: 2026-02-26 12:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "6b3b4083c5aa"
down_revision = "57122d037335"
@@ -10,7 +10,6 @@ from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "6f4f86aef280"
down_revision = "03d710ccf29c"
@@ -9,7 +9,6 @@ Create Date: 2025-01-13 18:12:18.029112
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "6fc7886d665d"
down_revision = "3c6531f32351"
@@ -9,7 +9,6 @@ Create Date: 2025-12-21 00:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7206234e012a"
down_revision = "699221885109"
@@ -13,7 +13,6 @@ This migration fixes the ProcessingMode enum value mismatch:
from alembic import op
# revision identifiers, used by Alembic.
revision = "72aa7de2e5cf"
down_revision = "2020d417ec84"
@@ -9,7 +9,6 @@ Create Date: 2026-02-23 12:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7616121f6e97"
down_revision = "07b98176f1de"
@@ -9,7 +9,6 @@ Create Date: 2023-09-21 10:03:21.509899
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "767f1c2a00eb"
down_revision = "dba7f71618f5"
@@ -9,7 +9,6 @@ Create Date: 2023-11-01 12:33:01.999617
from alembic import op
from sqlalchemy import String
# revision identifiers, used by Alembic.
revision = "77d07dffae64"
down_revision = "d61e513bef0a"
@@ -9,7 +9,6 @@ Create Date: 2024-07-19 11:54:35.701558
from alembic import op
import sqlalchemy as sa
revision = "795b20b85b4b"
down_revision = "05c07bf07c00"
branch_labels: None = None
@@ -9,7 +9,6 @@ Create Date: 2024-09-11 14:51:49.785835
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "797089dfb4d2"
down_revision = "55546a7967ee"
@@ -11,7 +11,6 @@ import json
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7b9b952abdf6"
down_revision = "36e9220ab794"
@@ -9,7 +9,6 @@ Create Date: 2026-02-22 18:54:54.007265
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7cb492013621"
down_revision = "0bb4558f35df"
@@ -9,7 +9,6 @@ Create Date: 2025-12-29 16:54:36.635574
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "7e490836d179"
down_revision = "c1d2e3f4a5b6"
@@ -8,7 +8,6 @@ Create Date: 2023-10-15 22:48:15.487762
from alembic import op
# revision identifiers, used by Alembic.
revision = "7f99be1cb9f5"
down_revision = "78dbe7e38469"
@@ -8,7 +8,6 @@ Create Date: 2026-03-31 19:23:05.753184
from alembic import op
# revision identifiers, used by Alembic.
revision = "8188861f4e92"
down_revision = "d8cdfee5df80"
@@ -12,7 +12,6 @@ from sqlalchemy.dialects import postgresql
from onyx.configs.constants import DocumentSource
# revision identifiers, used by Alembic.
revision = "81c22b1e2e78"
down_revision = "72aa7de2e5cf"
@@ -8,7 +8,6 @@ Create Date: 2026-01-07 16:43:44.855156
from alembic import op
# revision identifiers, used by Alembic.
revision = "8405ca81cc83"
down_revision = "a3c1a7904cd0"
@@ -30,7 +30,6 @@ Create Date: 2026-04-19 18:00:00.000000
from alembic import op
# revision identifiers, used by Alembic.
revision = "856bcbe14d79"
down_revision = "91d150c361f6"
@@ -9,7 +9,6 @@ Create Date: 2025-12-05 15:54:06.002452
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "87c52ec39f84"
down_revision = "7bd55f264e1b"
@@ -9,7 +9,6 @@ Create Date: 2024-12-20 13:29:09.918661
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "8e1ac4f39a9f"
down_revision = "9aadf32dfeb4"
@@ -9,7 +9,6 @@ Create Date: 2023-09-13 18:34:31.327944
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "8e26726b7683"
down_revision = "5809c0787398"
@@ -8,7 +8,6 @@ Create Date: 2025-02-24 17:35:33.072714
from alembic import op
# revision identifiers, used by Alembic.
revision = "8f43500ee275"
down_revision = "da42808081e3"
@@ -9,7 +9,6 @@ Create Date: 2026-02-23 10:48:48.343826
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "8ffcc2bcfc11"
down_revision = "7616121f6e97"
@@ -9,7 +9,6 @@ Create Date: 2026-01-05 00:00:00.000000
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "9087b548dd69"
down_revision = "2b90f3af54b8"
@@ -9,7 +9,6 @@ Create Date: 2026-01-26 09:13:09.635427
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "90b409d06e50"
down_revision = "f220515df7b4"
@@ -165,7 +165,7 @@ def remove_old_tags() -> None:
)
)
n_deleted += result.rowcount
logger.info(f"Processed {len(batch)} documents and deleted {n_deleted} tags")
logger.info("Processed %s documents and deleted %s tags", len(batch), n_deleted)
def active_search_settings() -> tuple[SearchSettings, SearchSettings | None]:
@@ -12,7 +12,6 @@ from sqlalchemy import column
from sqlalchemy import true
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "93a2e195e25c"
down_revision = "27fb147a843f"
@@ -9,7 +9,6 @@ Create Date: 2026-02-11 23:07:34.576725
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "93c15d6a6fbb"
down_revision = "d3fd499c829c"
@@ -18,7 +18,6 @@ from onyx.db.models import (
IndexAttempt,
)
# revision identifiers, used by Alembic.
revision = "949b4a92a401"
down_revision = "1b10e1fda030"
@@ -9,7 +9,6 @@ Create Date: 2024-12-11 11:26:10.616722
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "94dc3d0236f8"
down_revision = "bf7a81109301"
Loaded 100 of 544 files, more files were not shown because too many files have changed in this diff. Show more