Use foreign key constraints

Signed-off-by: Damon Kaswell <damon.kaswell1@hp.com>
This commit is contained in:
Damon Kaswell
2022-11-17 13:23:52 -08:00
committed by Fredrik Adelöw
parent 25da47e68d
commit b6d0c26902
2 changed files with 24 additions and 6 deletions
@@ -111,6 +111,9 @@ exports.up = async function up(knex) {
table
.uuid('ingestion_id')
.notNullable()
.references('id')
.inTable('ingestions')
.onDelete('CASCADE')
.comment('The id of the ingestion in which this mark took place');
table
@@ -148,6 +151,9 @@ exports.up = async function up(knex) {
table
.uuid('ingestion_mark_id')
.notNullable()
.references('id')
.inTable('ingestion_marks')
.onDelete('CASCADE')
.comment(
'Every time a mark happens during an ingestion, there are a list of entities marked.',
);
@@ -280,12 +280,24 @@ export class IncrementalIngestionEngine implements IterationEngine {
},
})) ?? [];
const removed: DeferredEntity[] = done
? []
: await this.manager.computeRemoved(
this.options.provider.getProviderName(),
id,
);
const removed: DeferredEntity[] = [];
let doComputeRemoved = false;
if (!done) {
doComputeRemoved = true;
} else {
if (entities && entities.length > 0) {
doComputeRemoved = true;
}
}
if(doComputeRemoved) {
removed.push(...await this.manager.computeRemoved(
this.options.provider.getProviderName(),
id,
));
}
await this.options.connection.applyMutation({
type: 'delta',