mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(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:
parent
51a34835c5
commit
0549e46380
@ -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;
|
||||
});
|
||||
|
@ -139,8 +139,7 @@ export async function main() {
|
||||
|
||||
await fixSiteProducts({
|
||||
deploymentType: server.getDeploymentType(),
|
||||
db: server.getHomeDBManager(),
|
||||
dry: true
|
||||
db: server.getHomeDBManager()
|
||||
});
|
||||
|
||||
return server;
|
||||
|
Loading…
Reference in New Issue
Block a user