(connection: Connection, plan: Sequence[TablePlan])
| 117 | |
| 118 | |
| 119 | def ensure_target_empty(connection: Connection, plan: Sequence[TablePlan]) -> None: |
| 120 | non_empty: list[str] = [] |
| 121 | for item in plan: |
| 122 | count = connection.execute(select(func.count()).select_from(item.target_table)).scalar_one() |
| 123 | if count: |
| 124 | non_empty.append(f"{item.name}={count}") |
| 125 | if non_empty: |
| 126 | raise MigrationError( |
| 127 | "目标库不是空库。请加上 --truncate-target 后重试。非空表: " + ", ".join(non_empty[:8]) |
| 128 | ) |
| 129 | |
| 130 | |
| 131 | def fetch_source_rows(connection: Connection, plan: TablePlan) -> list[dict]: |
no test coverage detected