This commit is contained in:
2026-08-16 12:00:28 +02:00
parent 52f27e30fc
commit 52fb129957
7 changed files with 105 additions and 23 deletions
+19
View File
@@ -433,6 +433,25 @@ func cloneCompanyCatalog(ctx context.Context, pool *pgxpool.Pool, src, dest uuid
}
add("company_language", ct.RowsAffected())
ct, err = tx.Exec(ctx, `
INSERT INTO company_settings (company_id, settings, updated_at)
SELECT $2, settings, now()
FROM company_settings WHERE company_id = $1
ON CONFLICT (company_id) DO UPDATE
SET settings = EXCLUDED.settings, updated_at = now()`, src, dest)
if err != nil {
return nil, fmt.Errorf("company_settings: %w", err)
}
add("company_settings", ct.RowsAffected())
// Cloned raws are ready to process on the destination (source flags may say processed).
if _, err := tx.Exec(ctx, `
UPDATE raw_products
SET is_processed = false, processing_status = 'unprocessed', updated_at = now()
WHERE company_id = $1`, dest); err != nil {
return nil, fmt.Errorf("reset raw processing flags: %w", err)
}
if err := tx.Commit(ctx); err != nil {
return nil, err
}