Database migration fails from HSQLDB - Cannot insert the value NULL into column user_name

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

External database migration fails from HSQLDB:

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

  1. Stop Bitbucket Server.
  2. 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 in BITBUCKET_HOME/data/db.script:
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:

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:

SELECT * FROM cwd_user WHERE user_name = 'null';

Second, update them:

UPDATE cwd_user SET user_name = 'null_value' WHERE user_name = 'null';

 

 

 

Resolution

An internal development task has been created to track this issue.
Last modified on Nov 2, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.