mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
Merge pull request #12819 from ToolJet/fix/migration-license-plan
fix: super admin issue
This commit is contained in:
commit
1acb1adfcb
1 changed files with 29 additions and 1 deletions
|
|
@ -16,7 +16,9 @@ export class EnforceNewBasicPlanLimits1742369617678 implements MigrationInterfac
|
|||
}
|
||||
const manager = queryRunner.manager;
|
||||
const nestApp = await NestFactory.createApplicationContext(await AppModule.register({ IS_GET_CONTEXT: true }));
|
||||
const { LicenseCountsService } = await import(`${await getImportPath(true, edition)}/licensing/services/count.service`);
|
||||
const { LicenseCountsService } = await import(
|
||||
`${await getImportPath(true, edition)}/licensing/services/count.service`
|
||||
);
|
||||
const licenseInitService = nestApp.get(LicenseInitService);
|
||||
|
||||
const { isValid } = await licenseInitService.initForMigration(manager);
|
||||
|
|
@ -170,6 +172,32 @@ export class EnforceNewBasicPlanLimits1742369617678 implements MigrationInterfac
|
|||
await manager.query(archiveViewersInstanceQuery);
|
||||
}
|
||||
}
|
||||
|
||||
const superAdminCountQuery = `
|
||||
SELECT COUNT(*) FROM users
|
||||
WHERE status = '${USER_STATUS.ACTIVE}' AND user_type = '${USER_TYPE.INSTANCE}'
|
||||
`;
|
||||
const superAdminCount = await manager.query(superAdminCountQuery);
|
||||
|
||||
if (superAdminCount === 0) {
|
||||
const superAdminsQuery = `
|
||||
SELECT * FROM users
|
||||
WHERE user_type = '${USER_TYPE.INSTANCE}'
|
||||
ORDER BY id ASC
|
||||
`;
|
||||
const superAdmins = await manager.query(superAdminsQuery);
|
||||
|
||||
if (superAdmins.length > 0) {
|
||||
const oneInstanceUser = superAdmins[0];
|
||||
console.log('Activating one instance user:', oneInstanceUser.id, oneInstanceUser.email);
|
||||
const activateUserQuery = `
|
||||
UPDATE users
|
||||
SET status = '${USER_STATUS.ACTIVE}'
|
||||
WHERE id = '${oneInstanceUser.id}'
|
||||
`;
|
||||
await manager.query(activateUserQuery);
|
||||
}
|
||||
}
|
||||
}
|
||||
await nestApp.close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue