(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
This commit is contained in:
Jarosław Sadziński 2024-06-18 18:29:06 +02:00
parent 51a34835c5
commit 0549e46380
2 changed files with 8 additions and 25 deletions

View File

@ -483,10 +483,9 @@ async function forEachWithBreaks<T>(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;
});

View File

@ -139,8 +139,7 @@ export async function main() {
await fixSiteProducts({
deploymentType: server.getDeploymentType(),
db: server.getHomeDBManager(),
dry: true
db: server.getHomeDBManager()
});
return server;