"Cannot insert the value NULL into column 'AccessToken'..." after upgrade or DB move
kbt134241
PRODUCTIssue
Sometimes, it is necessary to move your K2 database to a different SQL instance. This usually requires you to recreate the K2 master keys for SQL encryption.
Symptoms
In this case, the K2 database was moved prior to upgrading from K2 blackpearl 4.6.11 to 4.7.
The following error is logged in the installer trace file:
This error can appear whenever the K2 master keys are manually recreated on a K2 database that was moved, or after server relocation.
Resolution
If the issue occurred during an upgrade:
1. Restore to the pre-upgrade version of K2.
2. Run the following commands on the ‘K2’ database (replace with your K2 database name if different)
DELETE FROM [K2].[Authorization].[OAuthAppOnlyToken]
DELETE FROM [K2].[Authorization].[OAuthToken]
DELETE FROM [K2].[Authorization].[OAuthIdentity]
3. Rerun the Upgrade/Update
If this occurred outside the context of an upgrade, you can skip step 1, and rerun the last-applied update.