Database migration fails from HSQLDB - Cannot insert the value NULL into column user_name
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Symptoms
External database migration fails from HSQLDB:
1
2
3
4
5
2013-03-06 15:57:20,836 ERROR [threadpool:thread-3] tester 939x54x1 9x6sca 10.95.31.99 "POST /admin/db/edit HTTP/1.1" c.a.s.i.m.FullMigrationMaintenanceTask Reverting database configuration after a failed migration attempt
com.atlassian.bitbucket.internal.backup.liquibase.LiquibaseChangeExecutionException: Failed to execute change: Insert Row; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'user_name', table 'Bitbucket Server.dbo.cwd_user'; column does not allow nulls. INSERT fails.
...
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'user_name', table 'Bitbucket Server.dbo.cwd_user'; column does not allow nulls. INSERT fails.
...
Cause
Values that match the string null
are actually transformed into a null value (NULL) which prevents successful completion of the migration.
Workaround
Stop Bitbucket Server.
Either connect to the Bitbucket Server database and rename the offending table entries directly (table
CWD_USER
, see the schema below) or rename the values inBITBUCKET_HOME/data/db.script
:
1
2
3
INSERT INTO CWD_USER VALUES(298135,'null','null','T','2013-02-15
10:25:38.301000','2013-02-15
10:25:38.301000','null','null','null','null','null','null','null@atlassian.com','null@atlassian.com',229377,'nopass')
For reference, this is the table schema:
1
ID USER_NAME LOWER_USER_NAME ACTIVE CREATED_DATE UPDATED_DATE FIRST_NAME LOWER_FIRST_NAME LAST_NAME LOWER_LAST_NAME DISPLAY_NAME LOWER_DISPLAY_NAME EMAIL_ADDRESS LOWER_EMAIL_ADDRESS DIRECTORY_ID CREDENTIAL
For example, to modify the database, first locate the offending entries:
1
SELECT * FROM cwd_user WHERE user_name = 'null';
Second, update them:
1
UPDATE cwd_user SET user_name = 'null_value' WHERE user_name = 'null';
Resolution
An internal development task has been created to track this issue.
Was this helpful?