File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
packages/backend/src/models Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -109,15 +109,29 @@ class FlowConnections extends Base {
109109 if ( hasCollaborators ) {
110110 // NOTE: somehow .onConflict().ignore() does not return an empty array
111111 // on conflict, but actually returns the row its trying to insert
112- const existing = await this . query ( trx ) . findOne ( {
113- flow_id : flowId ,
114- connection_id : connectionId ,
115- } )
112+
113+ // check if the connection existed before and was deleted
114+ const existing = await this . query ( trx )
115+ . findOne ( {
116+ flow_id : flowId ,
117+ connection_id : connectionId ,
118+ } )
119+ . withSoftDeleted ( )
116120
117121 if ( existing ) {
118- return null
122+ // if it existed before and was deleted, restore it
123+ return await this . query ( trx )
124+ . where ( {
125+ flow_id : flowId ,
126+ connection_id : connectionId ,
127+ } )
128+ . patch ( {
129+ deletedAt : null ,
130+ } )
131+ . withSoftDeleted ( )
119132 }
120133
134+ // if it did not exist before, add it
121135 return await this . query ( trx )
122136 . insert ( {
123137 flowId,
You can’t perform that action at this time.
0 commit comments