mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 05:18:11 +00:00
@@ -29,11 +29,13 @@ type SeedOrganization = {
|
||||
export class EdrOrgSeeder {
|
||||
private readonly logger = new Logger(EdrOrgSeeder.name);
|
||||
|
||||
constructor(private readonly dataSource: DataSource) {}
|
||||
constructor(private readonly dataSource: DataSource) { }
|
||||
|
||||
async run() {
|
||||
if (!this.shouldSeed()) {
|
||||
this.logger.log(`Skipping EDR org seed because ${SEED_FLAG} is not enabled`);
|
||||
this.logger.log(
|
||||
`Skipping EDR org seed because ${SEED_FLAG} is not enabled`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,20 +97,22 @@ export class EdrOrgSeeder {
|
||||
manager: EntityManager,
|
||||
organizationId: string,
|
||||
) {
|
||||
const organizationConfigurationRepository =
|
||||
manager.getRepository(OrganizationConfiguration);
|
||||
|
||||
await organizationConfigurationRepository.upsert({
|
||||
organizationId,
|
||||
canCreateBranchByItself: true,
|
||||
canStartReceivingRecord: true,
|
||||
}, {
|
||||
conflictPaths: { organizationId: true },
|
||||
});
|
||||
|
||||
this.logger.log(
|
||||
`Ensured organization configuration for '${EDR_ORG_KEY}'`,
|
||||
const organizationConfigurationRepository = manager.getRepository(
|
||||
OrganizationConfiguration,
|
||||
);
|
||||
|
||||
await organizationConfigurationRepository.upsert(
|
||||
{
|
||||
organizationId,
|
||||
canCreateBranchByItself: true,
|
||||
canStartReceivingRecord: true,
|
||||
},
|
||||
{
|
||||
conflictPaths: { organizationId: true },
|
||||
},
|
||||
);
|
||||
|
||||
this.logger.log(`Ensured organization configuration for '${EDR_ORG_KEY}'`);
|
||||
}
|
||||
|
||||
private async ensureDefaultUnit(
|
||||
@@ -152,7 +156,9 @@ export class EdrOrgSeeder {
|
||||
key: EDR_FREIGHT_APPLICATION.key,
|
||||
name: { ...EDR_FREIGHT_APPLICATION.name },
|
||||
});
|
||||
this.logger.log(`Seeded EDR application '${EDR_FREIGHT_APPLICATION.key}'`);
|
||||
this.logger.log(
|
||||
`Seeded EDR application '${EDR_FREIGHT_APPLICATION.key}'`,
|
||||
);
|
||||
return { id: insertResult.identifiers[0]?.id as string };
|
||||
}
|
||||
|
||||
@@ -181,7 +187,8 @@ export class EdrOrgSeeder {
|
||||
applicationId,
|
||||
})),
|
||||
)
|
||||
.orUpdate(["name", "application_id"], ["key"])
|
||||
.orIgnore()
|
||||
// .orUpdate(["name", "application_id"], ["key"])
|
||||
.execute();
|
||||
|
||||
this.logger.log(
|
||||
|
||||
Reference in New Issue
Block a user