style: apply ruff auto-fix
- Auto-formatted code with ruff format - Applied ruff linting fixes with --fix Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
+8
-8
@@ -210,10 +210,10 @@ def _run_schema_migrations(engine: Any) -> None:
|
|||||||
if unique_filehash_indexes:
|
if unique_filehash_indexes:
|
||||||
logger.info("Migrating files: dropping unique index on 'filehash'")
|
logger.info("Migrating files: dropping unique index on 'filehash'")
|
||||||
with engine.begin() as conn:
|
with engine.begin() as conn:
|
||||||
preparer = conn.dialect.identifier_preparer
|
preparer = conn.dialect.identifier_preparer
|
||||||
for index in unique_filehash_indexes:
|
for index in unique_filehash_indexes:
|
||||||
quoted_idx = preparer.quote(index["name"])
|
quoted_idx = preparer.quote(index["name"])
|
||||||
conn.execute(text(f"DROP INDEX IF EXISTS {quoted_idx}"))
|
conn.execute(text(f"DROP INDEX IF EXISTS {quoted_idx}"))
|
||||||
logger.info("Migration complete: unique index on 'filehash' removed")
|
logger.info("Migration complete: unique index on 'filehash' removed")
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning(f"Skipping filehash unique index drop: {exc}")
|
logger.warning(f"Skipping filehash unique index drop: {exc}")
|
||||||
@@ -265,16 +265,16 @@ def _ensure_indexes(engine: Any, inspector: Any) -> None:
|
|||||||
table_names = inspector.get_table_names()
|
table_names = inspector.get_table_names()
|
||||||
columns_by_table: dict[str, set[str]] = {}
|
columns_by_table: dict[str, set[str]] = {}
|
||||||
with engine.begin() as conn:
|
with engine.begin() as conn:
|
||||||
preparer = conn.dialect.identifier_preparer
|
preparer = conn.dialect.identifier_preparer
|
||||||
for idx_name, table, column in _PERF_INDEXES:
|
for idx_name, table, column in _PERF_INDEXES:
|
||||||
if table in table_names:
|
if table in table_names:
|
||||||
if table not in columns_by_table:
|
if table not in columns_by_table:
|
||||||
columns_by_table[table] = {col["name"] for col in inspector.get_columns(table)}
|
columns_by_table[table] = {col["name"] for col in inspector.get_columns(table)}
|
||||||
if column in columns_by_table[table]:
|
if column in columns_by_table[table]:
|
||||||
quoted_idx = preparer.quote(idx_name)
|
quoted_idx = preparer.quote(idx_name)
|
||||||
quoted_table = preparer.quote(table)
|
quoted_table = preparer.quote(table)
|
||||||
quoted_col = preparer.quote(column)
|
quoted_col = preparer.quote(column)
|
||||||
conn.execute(text(f"CREATE INDEX IF NOT EXISTS {quoted_idx} ON {quoted_table} ({quoted_col})"))
|
conn.execute(text(f"CREATE INDEX IF NOT EXISTS {quoted_idx} ON {quoted_table} ({quoted_col})"))
|
||||||
|
|
||||||
logger.info("Performance indexes ensured")
|
logger.info("Performance indexes ensured")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user