From 0549e46380948856e7e3edc757466fd37d8d596c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Tue, 18 Jun 2024 18:29:06 +0200 Subject: [PATCH] (core) Removing dry option from fixSiteProducts Summary: fixSiteProducts was always called with a dry option. This option was just added for debuging test failure, it should have been removed. Test Plan: Manual. - on grist core, prepare site with `teamFree` product - then to recreate run the previous version as `GRIST_SINGLE_ORG=cool-beans GRIST_DEFAULT_PRODUCT=Free npm start` - then to confirm it is fixed, run the same command as above Site should be changed from `teamFree` to `Free`. Reviewers: paulfitz Reviewed By: paulfitz Subscribers: paulfitz Differential Revision: https://phab.getgrist.com/D4276 --- app/gen-server/lib/Housekeeper.ts | 30 +++++++----------------------- stubs/app/server/server.ts | 3 +-- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/app/gen-server/lib/Housekeeper.ts b/app/gen-server/lib/Housekeeper.ts index 14c68ecf..116a3c50 100644 --- a/app/gen-server/lib/Housekeeper.ts +++ b/app/gen-server/lib/Housekeeper.ts @@ -483,10 +483,9 @@ async function forEachWithBreaks(logText: string, items: T[], callback: (item */ export async function fixSiteProducts(options: { deploymentType: string, - db: HomeDBManager, - dry?: boolean, + db: HomeDBManager }) { - const {deploymentType, dry, db} = options; + const {deploymentType, db} = options; const hasDefaultProduct = () => Boolean(process.env.GRIST_DEFAULT_PRODUCT); const defaultProductIsFree = () => process.env.GRIST_DEFAULT_PRODUCT === 'Free'; @@ -502,10 +501,8 @@ export async function fixSiteProducts(options: { } // Find all billing accounts on teamFree product and change them to the Free. - return await db.connection.transaction(async (t) => { const freeProduct = await t.findOne(Product, {where: {name: 'Free'}}); - const freeTeamProduct = await t.findOne(Product, {where: {name: 'teamFree'}}); if (!freeTeamProduct) { @@ -518,24 +515,11 @@ export async function fixSiteProducts(options: { return false; } - if (dry) { - await t.createQueryBuilder() - .select('ba') - .from(BillingAccount, 'ba') - .where('ba.product = :productId', {productId: freeTeamProduct.id}) - .getMany() - .then((accounts) => { - accounts.forEach(a => { - console.log(`Would change account ${a.id} from ${a.product.id} to ${freeProduct.id}`); - }); - }); - } else { - await t.createQueryBuilder() - .update(BillingAccount) - .set({product: freeProduct.id}) - .where({product: freeTeamProduct.id}) - .execute(); - } + await t.createQueryBuilder() + .update(BillingAccount) + .set({product: freeProduct.id}) + .where({product: freeTeamProduct.id}) + .execute(); return true; }); diff --git a/stubs/app/server/server.ts b/stubs/app/server/server.ts index b6f272a9..e8761cef 100644 --- a/stubs/app/server/server.ts +++ b/stubs/app/server/server.ts @@ -139,8 +139,7 @@ export async function main() { await fixSiteProducts({ deploymentType: server.getDeploymentType(), - db: server.getHomeDBManager(), - dry: true + db: server.getHomeDBManager() }); return server;