Delete collections item first

Fixes #3593
This commit is contained in:
rijkvanzanten
2021-01-12 16:23:30 -05:00
parent c3881b0110
commit f00a38737b

View File

@@ -260,6 +260,12 @@ export class CollectionsService {
throw new ForbiddenException('Only admins can perform this action.');
}
const collectionItemsService = new ItemsService('directus_collections', {
knex: this.knex,
accountability: this.accountability,
schema: this.schema,
});
const fieldsService = new FieldsService({
knex: this.knex,
accountability: this.accountability,
@@ -276,6 +282,8 @@ export class CollectionsService {
}
}
await collectionItemsService.delete(collectionKeys);
await this.knex('directus_fields').delete().whereIn('collection', collectionKeys);
await this.knex('directus_presets').delete().whereIn('collection', collectionKeys);
await this.knex('directus_revisions').delete().whereIn('collection', collectionKeys);
@@ -305,14 +313,6 @@ export class CollectionsService {
}
}
const collectionItemsService = new ItemsService('directus_collections', {
knex: this.knex,
accountability: this.accountability,
schema: this.schema,
});
await collectionItemsService.delete(collectionKeys);
for (const collectionKey of collectionKeys) {
await this.knex.schema.dropTable(collectionKey);
}