Skip to content

Commit

Permalink
fix(core): Fix deletion of Collections
Browse files Browse the repository at this point in the history
Closes #297. The error was due to a foreign key violation on the CollectionAsset. Fixed by adding a delete cascade to the CollectionAsset

BREAKING CHANGE: The CollectionAsset entity had a cascade delete defined, which will require a DB migration.
  • Loading branch information
michaelbromley committed Apr 7, 2020
1 parent e304ae2 commit 44916b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/core/e2e/collection.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ describe('Collection resolver', () => {
translations: [
{ languageCode: LanguageCode.en, name: 'Delete Me Parent', description: '' },
],
assetIds: ['T_1'],
},
},
);
Expand All @@ -500,6 +501,7 @@ describe('Collection resolver', () => {
{ languageCode: LanguageCode.en, name: 'Delete Me Child', description: '' },
],
parentId: collectionToDeleteParent.id,
assetIds: ['T_2'],
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export class CollectionAsset extends OrderableAsset {
@Column()
collectionId: ID;

@ManyToOne(type => Collection, collection => collection.assets)
@ManyToOne((type) => Collection, (collection) => collection.assets, { onDelete: 'CASCADE' })
collection: Collection;
}

0 comments on commit 44916b7

Please sign in to comment.