From dfeb70d7fb916e719e566090f35ea84e7c443c6d Mon Sep 17 00:00:00 2001 From: wangsijie Date: Wed, 20 Nov 2024 14:37:26 +0800 Subject: [PATCH] fix(schemas): resolve duplicates of init account center alter --- .../alterations/next-1731054001-init-account-center.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/schemas/alterations/next-1731054001-init-account-center.ts b/packages/schemas/alterations/next-1731054001-init-account-center.ts index 8387a1adde3..63273b6346d 100644 --- a/packages/schemas/alterations/next-1731054001-init-account-center.ts +++ b/packages/schemas/alterations/next-1731054001-init-account-center.ts @@ -4,6 +4,13 @@ import type { AlterationScript } from '../lib/types/alteration.js'; const alteration: AlterationScript = { up: async (pool) => { + // Delete the default account center if it exists + const { rowCount } = await pool.query(sql` + delete from account_centers where id = 'default'; + `); + + console.log(`Deleted ${rowCount} default account center`); + // Process in chunks of 1000 tenants const batchSize = 1000; // eslint-disable-next-line @silverhand/fp/no-let @@ -26,7 +33,7 @@ const alteration: AlterationScript = { // eslint-disable-next-line no-await-in-loop await pool.query(sql` insert into account_centers (tenant_id, id) - values ${sql.join(values, sql`, `)}; + values ${sql.join(values, sql`, `)} `); // eslint-disable-next-line @silverhand/fp/no-mutation