Revert "KI-AGENT: Exportiere Sachkonten beim Mandantenumzug"
This reverts commit 30aaf141c7.
This commit is contained in:
@@ -123,7 +123,6 @@ export const buildTenantFullExport = async (server: FastifyInstance, tenantId: n
|
||||
if (!tenantRows.length) throw new Error("Tenant nicht gefunden")
|
||||
|
||||
addRows(tables, "tenants", tenantRows)
|
||||
addRows(tables, "accounts", await loadRows(client, "accounts", `${quoteIdent("accountChart")} = $1`, [tenantRows[0].accountChart || "skr03"]))
|
||||
|
||||
for (const [table, metadata] of columnsByTable.entries()) {
|
||||
if (table === "tenants") continue
|
||||
@@ -287,15 +286,8 @@ const insertRows = async (client: any, table: string, rows: Record<string, any>[
|
||||
const placeholders = rowColumns.map((_, index) => `$${index + 1}`).join(", ")
|
||||
const values = rowColumns.map((column) => prepareColumnValue(row[column], metadata.jsonColumns.has(column)))
|
||||
|
||||
const conflictSql = table === "tenants" && rowColumns.includes("id")
|
||||
? `on conflict (${quoteIdent("id")}) do update set ${rowColumns
|
||||
.filter((column) => column !== "id")
|
||||
.map((column) => `${quoteIdent(column)} = excluded.${quoteIdent(column)}`)
|
||||
.join(", ")}`
|
||||
: "on conflict do nothing"
|
||||
|
||||
await client.query(
|
||||
`insert into ${quoteIdent(table)} (${rowColumns.map(quoteIdent).join(", ")}) values (${placeholders}) ${conflictSql}`,
|
||||
`insert into ${quoteIdent(table)} (${rowColumns.map(quoteIdent).join(", ")}) values (${placeholders}) on conflict do nothing`,
|
||||
values
|
||||
)
|
||||
inserted += 1
|
||||
@@ -336,7 +328,6 @@ export const importTenantFullExport = async (
|
||||
const client = await pool.connect()
|
||||
const importOrder = [
|
||||
"tenants",
|
||||
"accounts",
|
||||
"auth_users",
|
||||
"auth_roles",
|
||||
"auth_role_permissions",
|
||||
|
||||
Reference in New Issue
Block a user