Skip to content

Commit 12cdaf6

Browse files
authored
PLU-615: cascade flow_connections (#1332)
## TL;DR Deleting a connection from `connections` does not cascade to `flow_connections`. ## What changed * Delete from `flow_connections` when a connection is deleted. * Add index on `connection_id` in `flow_connections` * Show `Not connected` for a collaborator when the connection is deleted. ## Tests 1. Delete a connection from a Pipe that has collaborators 2. Verify that the connection has been soft deleted in both `connections` and `flow_connections` 3. Should show 'Not connected' on the UI ## Deploy Notes - [ ] Run migration `20251124023536_add_index_on_flow_connections.ts`
1 parent 3d9f343 commit 12cdaf6

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Knex } from 'knex'
2+
3+
export async function up(knex: Knex): Promise<void> {
4+
await knex.schema.table('flow_connections', (table) => {
5+
table.index(['connection_id'])
6+
})
7+
}
8+
9+
export async function down(knex: Knex): Promise<void> {
10+
await knex.schema.table('flow_connections', (table) => {
11+
table.dropIndex(['connection_id'])
12+
})
13+
}
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1+
import FlowConnections from '@/models/flow-connections'
2+
13
import type { MutationResolvers } from '../__generated__/types.generated'
24

35
const deleteConnection: MutationResolvers['deleteConnection'] = async (
46
_parent,
57
params,
68
context,
79
) => {
8-
await context.currentUser
9-
.$relatedQuery('connections')
10-
.delete()
11-
.findOne({
12-
id: params.input.id,
13-
})
14-
.throwIfNotFound()
10+
return await FlowConnections.transaction(async (trx) => {
11+
await context.currentUser
12+
.$relatedQuery('connections', trx)
13+
.delete()
14+
.findOne({
15+
id: params.input.id,
16+
})
17+
.throwIfNotFound()
18+
19+
// also delete the connection from the flow_connections table for flows with collaborators
20+
await FlowConnections.query(trx)
21+
.delete()
22+
.where({ connection_id: params.input.id })
1523

16-
return true
24+
return true
25+
})
1726
}
1827

1928
export default deleteConnection

0 commit comments

Comments
 (0)