Microsoft Teams for Jira has the same OAuth key and ID after migration
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
After restoring an XML backup into a new instance, the Microsoft Teams for Jira configuration page retains the OAuth key and Jira ID from the original instance.
Diagnosis
- After creating a new application link, the Jira ID from the original instance is provided as part of the integration:
- Uninstalling and reinstalling the app (or recreating the application link) does not resolve the problem.
Cause
The integration data is stored within the database and is not cleared when removing the app or application link.
Resolution
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
To clean the Jira Server database from tables generated by the app, run the following scripts:
DECLARE @cmd varchar(4000)
DECLARE cmds CURSOR FOR
SELECT 'drop table [' + Table_Name + ']'
FROM INFORMATION_SCHEMA.TABLES
WHERE Table_Name LIKE 'AO%APP_KEYS' OR Table_Name LIKE 'AO%TEAMS_ATLAS_USER'
OPEN cmds
WHILE 1 = 1
BEGIN
FETCH cmds INTO @cmd
IF @@fetch_status != 0 BREAK
EXEC(@cmd)
END
CLOSE cmds;
DEALLOCATE cmds
SET @tables := NULL;
SELECT GROUP_CONCAT(TABLE_NAME) INTO @tables FROM information_schema.tables
WHERE TABLE_NAME LIKE BINARY 'AO%APP_KEYS' OR TABLE_NAME LIKE BINARY 'AO%TEAMS_ATLAS_USER';
SET @tables = IFNULL(CONCAT('DROP TABLE ', @tables),'SELECT NULL;');
PREPARE stmt1 FROM @tables;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
BEGIN
FOR c IN ( SELECT table_name FROM user_tables WHERE table_name LIKE 'AO%TEAMS_ATLAS_USER' OR table_name LIKE 'AO%_APP_KEYS' )
LOOP
EXECUTE IMMEDIATE 'DROP TABLE ' || c.table_name;
END LOOP;
END;
DROP SEQUENCE AO_A07C39_TEAMS_ATL2031287131;
DROP SEQUENCE AO_A07C39_APP_KEYS_ID_SEQ;
DO
$do$
DECLARE
_tbl text;
BEGIN
FOR _tbl IN
SELECT quote_ident(table_name)
FROM information_schema.tables
WHERE table_name LIKE 'AO%APP_KEYS' OR table_name LIKE 'AO%TEAMS_ATLAS_USER'
LOOP
EXECUTE 'DROP TABLE ' || _tbl;
END LOOP;
END
$do$;