Skip to content

Commit

Permalink
fix(core): Fix edge case FK error when creating new Collections
Browse files Browse the repository at this point in the history
Fixes #1215
  • Loading branch information
michaelbromley committed Nov 23, 2021
1 parent 5cd8e1a commit 160f457
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/service/services/collection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,10 @@ export class CollectionService implements OnModuleInit {
return this.rootCollection;
}

const rootTranslation = await this.connection.getRepository(ctx, CollectionTranslation).save(
// We purposefully do not use the ctx in saving the new root Collection
// so that even if the outer transaction fails, the root collection will still
// get persisted.
const rootTranslation = await this.connection.getRepository(CollectionTranslation).save(
new CollectionTranslation({
languageCode: this.configService.defaultLanguageCode,
name: ROOT_COLLECTION_NAME,
Expand All @@ -622,7 +625,7 @@ export class CollectionService implements OnModuleInit {
}),
);

const newRoot = await this.connection.getRepository(ctx, Collection).save(
const newRoot = await this.connection.getRepository(Collection).save(
new Collection({
isRoot: true,
position: 0,
Expand Down

0 comments on commit 160f457

Please sign in to comment.