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: {
|
export async function fixSiteProducts(options: {
|
||||||
deploymentType: string,
|
deploymentType: string,
|
||||||
db: HomeDBManager,
|
db: HomeDBManager
|
||||||
dry?: boolean,
|
|
||||||
}) {
|
}) {
|
||||||
const {deploymentType, dry, db} = options;
|
const {deploymentType, db} = options;
|
||||||
|
|
||||||
const hasDefaultProduct = () => Boolean(process.env.GRIST_DEFAULT_PRODUCT);
|
const hasDefaultProduct = () => Boolean(process.env.GRIST_DEFAULT_PRODUCT);
|
||||||
const defaultProductIsFree = () => process.env.GRIST_DEFAULT_PRODUCT === 'Free';
|
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.
|
// Find all billing accounts on teamFree product and change them to the Free.
|
||||||
|
|
||||||
return await db.connection.transaction(async (t) => {
|
return await db.connection.transaction(async (t) => {
|
||||||
const freeProduct = await t.findOne(Product, {where: {name: 'Free'}});
|
const freeProduct = await t.findOne(Product, {where: {name: 'Free'}});
|
||||||
|
|
||||||
const freeTeamProduct = await t.findOne(Product, {where: {name: 'teamFree'}});
|
const freeTeamProduct = await t.findOne(Product, {where: {name: 'teamFree'}});
|
||||||
|
|
||||||
if (!freeTeamProduct) {
|
if (!freeTeamProduct) {
|
||||||
@ -518,24 +515,11 @@ export async function fixSiteProducts(options: {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dry) {
|
await t.createQueryBuilder()
|
||||||
await t.createQueryBuilder()
|
.update(BillingAccount)
|
||||||
.select('ba')
|
.set({product: freeProduct.id})
|
||||||
.from(BillingAccount, 'ba')
|
.where({product: freeTeamProduct.id})
|
||||||
.where('ba.product = :productId', {productId: freeTeamProduct.id})
|
.execute();
|
||||||
.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -139,8 +139,7 @@ export async function main() {
|
|||||||
|
|
||||||
await fixSiteProducts({
|
await fixSiteProducts({
|
||||||
deploymentType: server.getDeploymentType(),
|
deploymentType: server.getDeploymentType(),
|
||||||
db: server.getHomeDBManager(),
|
db: server.getHomeDBManager()
|
||||||
dry: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
|
Loading…
Reference in New Issue
Block a user