fix: reset ONBOARDING_COMPLETED to false during infra config reset (#5496)

fix: reset ONBOARDING_COMPLETED config to false on reset
This commit is contained in:
Mir Arif Hasan 2025-10-20 19:57:59 +06:00 committed by GitHub
parent c31f74829d
commit 6064186d30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -615,21 +615,26 @@ export class InfraConfigService implements OnModuleInit {
InfraConfigEnum.ALLOW_ANALYTICS_COLLECTION,
];
try {
const infraConfigDefaultObjs = await getDefaultInfraConfigs();
const updatedInfraConfigDefaultObjs = infraConfigDefaultObjs.filter(
const defaultConfigs = await getDefaultInfraConfigs();
const configsToReset = defaultConfigs.filter(
(p) => RESET_EXCLUSION_LIST.includes(p.name) === false,
);
// Update ONBOARDING_COMPLETED value to false
const onboardingCompletedIndex = configsToReset.findIndex(
(p) => p.name === InfraConfigEnum.ONBOARDING_COMPLETED,
);
if (onboardingCompletedIndex !== -1) {
configsToReset[onboardingCompletedIndex].value = 'false';
}
await this.prisma.infraConfig.deleteMany({
where: {
name: {
in: updatedInfraConfigDefaultObjs.map((p) => p.name),
},
},
where: { name: { in: configsToReset.map((p) => p.name) } },
});
await this.prisma.infraConfig.createMany({
data: updatedInfraConfigDefaultObjs,
data: configsToReset,
});
stopApp();