This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
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.
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:
"Could not recreate key: System.Data.SqlClient.SqlException (0x80131904): Error 515, Level 16, State 2, Procedure -, Line 6 Cannot insert the value NULL into column 'AccessToken', table 'K2.Authorization.OAuthToken'; column does not allow nulls. UPDATE fails."
This error can appear whenever the K2 master keys are manually recreated on a K2 database that was moved, or after server relocation.
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.