@@ -1509,6 +1509,17 @@ export default class IntegrationService {
15091509 IntegrationService . constructNangoConnectionPayload ( integrationData )
15101510
15111511 connectionId = await connectNangoIntegration ( confluenceIntegrationType , nangoPayload )
1512+
1513+ // Delete old integration record since we have a new connectionId
1514+ // (integration.id must match Nango connectionId for nango integrations other than GitHub)
1515+ this . options . log . info (
1516+ `Deleting old integration ${ existingIntegration . id } and creating new one with ${ connectionId } ` ,
1517+ )
1518+ await IntegrationRepository . destroy ( existingIntegration . id , {
1519+ ...this . options ,
1520+ transaction,
1521+ } )
1522+ await deleteNangoConnection ( confluenceIntegrationType , existingIntegration . id )
15121523 }
15131524
15141525 await setNangoMetadata ( NangoIntegration . CONFLUENCE_BASIC , connectionId , {
@@ -2206,6 +2217,17 @@ export default class IntegrationService {
22062217 `jira integration type determined: ${ jiraIntegrationType } , starting nango connection...` ,
22072218 )
22082219 connectionId = await connectNangoIntegration ( jiraIntegrationType , nangoPayload )
2220+
2221+ // Delete old integration record since we have a new connectionId
2222+ // (integration.id must match Nango connectionId for nango integrations other than GitHub)
2223+ this . options . log . info (
2224+ `Deleting old integration ${ existingIntegration . id } and creating new one with ${ connectionId } ` ,
2225+ )
2226+ await IntegrationRepository . destroy ( existingIntegration . id , {
2227+ ...this . options ,
2228+ transaction,
2229+ } )
2230+ await deleteNangoConnection ( jiraIntegrationType , existingIntegration . id )
22092231 }
22102232
22112233 await setNangoMetadata ( jiraIntegrationType , connectionId , {
0 commit comments