"Cannot insert NULL into attribute_name" error during Bitbucket Database migration
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
Summary
When using the database migration wizard to migrate a Bitbucket database migration from Oracle to MSSQL for instance, the export phase completes successfully.
However, the import into the target database fails with the following error:
"Cannot insert the value NULL into column 'attribute_name', table 'bitbucket.dbo.cwd_application_attribute'; column does not allow nulls. INSERT fails."
The error log contains the following:
2025-06-13 13:08:26,290 ERROR [threadpool:thread-4] user1 @WO0X3Rx1269x13622x0 12lnilk 10.255.XX.XX "POST /admin/db/edit HTTP/1.0" c.a.s.i.b.l.DefaultLiquibaseDao Unable to insert into table cwd_application_attribute data [application_id=32769] with statement insert into cwd_application_attribute (application_id) values (?)
2025-06-13 13:08:26,461 ERROR [threadpool:thread-4] user1 @WO0X3Rx1269x13622x0 12lnilk 10.255.XX.XX "POST /admin/db/edit HTTP/1.0" c.a.s.i.m.m.BaseMigrationTask Reverting database configuration after a failed migration attempt com.atlassian.stash.internal.backup.liquibase.LiquibaseChangeExecutionException: Failed to execute change: Inserts data into an existing table; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'attribute_name', table 'bitbucket.dbo.cwd_application_attribute'; column does not allow nulls. INSERT fails.
at com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseDao.insert(DefaultLiquibaseDao.java:313)
at com.atlassian.stash.internal.backup.liquibase.DatabaseUpdater.onChangesetContent(DatabaseUpdater.java:63)
at com.atlassian.stash.internal.backup.liquibase.ChangeSetReader.endElement(ChangeSetReader.java:63)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.atlassian.security.xml.RestrictedXMLReader.parse(RestrictedXMLReader.java:103)
at com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseMigrationDao.parse(DefaultLiquibaseMigrationDao.java:225)
at com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseMigrationDao.lambda$restore$0(DefaultLiquibaseMigrationDao.java:183)
at com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseDao.withLock(DefaultLiquibaseDao.java:340)
at com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseMigrationDao.restore(DefaultLiquibaseMigrationDao.java:179)
at com.atlassian.stash.internal.maintenance.restore.DatabaseRestoreStep.run(DatabaseRestoreStep.java:95)
at com.atlassian.stash.internal.maintenance.CompositeMaintenanceTask$Step.run(CompositeMaintenanceTask.java:135)
at com.atlassian.stash.internal.maintenance.CompositeMaintenanceTask.run(CompositeMaintenanceTask.java:71)
at com.atlassian.stash.internal.maintenance.restore.RestorePhase.run(RestorePhase.java:27)
at com.atlassian.stash.internal.maintenance.CompositeMaintenanceTask$Step.run(CompositeMaintenanceTask.java:135)
at com.atlassian.stash.internal.maintenance.CompositeMaintenanceTask.run(CompositeMaintenanceTask.java:71)
at com.atlassian.stash.internal.maintenance.CompositeMaintenanceTask$Step.run(CompositeMaintenanceTask.java:135)
at com.atlassian.stash.internal.maintenance.CompositeMaintenanceTask.run(CompositeMaintenanceTask.java:71)
at com.atlassian.stash.internal.maintenance.MaintenanceModePhase.run(MaintenanceModePhase.java:27)
at com.atlassian.stash.internal.maintenance.migration.BaseMigrationTask.run(BaseMigrationTask.java:68)
at com.atlassian.stash.internal.maintenance.migration.DatabaseMigrationTask.run(DatabaseMigrationTask.java:49)
at com.atlassian.stash.internal.maintenance.DefaultMaintenanceTaskMonitor.run(DefaultMaintenanceTaskMonitor.java:213)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at com.atlassian.stash.internal.concurrent.StateTransferringRunnable.run(StateTransferringRunnable.java:50)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
... 1 frame trimmed
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL into column 'attribute_name', table 'bitbucket.dbo.cwd_application_attribute'; column does not allow nulls. INSERT fails.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:265)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1662)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:615)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:537)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7417)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3488)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:262)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:237)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:483)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseDao.insert(DefaultLiquibaseDao.java:306)
... 37 common frames omitted
Environment
Bitbucket Data Center 8.19.0
Solution
Check source database table structure
The issue arises because the structure of the cwd_application_attribute
table in the source database differs from the original structure created by Bitbucket. Bitbucket does not expect null values in the attribute_name
column, but if null values are present due to some issue, they will not be inserted into the target database. This is because the target database's table is created by Bitbucket during the migration process, and it follows Bitbucket's specifications, which do not permit null values in that column.
The current table structure at the source database can be determined using the queries provided below. See below for queries for MSSQL, Oracle, and PostgreSQL.
SELECT column_name, data_type, character_maximum_length AS data_length, is_nullable
FROM information_schema.columns
WHERE table_name = 'cwd_application_attribute'
ORDER BY ordinal_position;
SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH, NULLABLE
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME = 'CWD_APPLICATION_ATTRIBUTE'
ORDER BY COLUMN_ID;
SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH AS DATA_LENGTH, IS_NULLABLE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'cwd_application_attribute'
ORDER BY ORDINAL_POSITION;
Adjust database tables
Back up your data before performing the modifications below to the database.
If possible, test the queries on a staging server first.
Reach out to Atlassian support if anything goes wrong or if you need assistance in understanding the procedure.
The default table structure at the source database should have the following configuration, so make sure the is_nullable
constraint matches these values. If there are discrepancies in other columns, consult Atlassian support.
For PostgreSQL
+---------------+-----------------+-----------+-----------+
|column_name |data_type |data_length|is_nullable|
+---------------+-----------------+-----------+-----------+
|application_id |bigint |null |NO |
|attribute_name |character varying|255 |NO |
|attribute_value|text |null |YES |
+---------------+-----------------+-----------+-----------+
For Oracle
+---------------+---------+-----------+--------+
|COLUMN_NAME |DATA_TYPE|DATA_LENGTH|NULLABLE|
+---------------+---------+-----------+--------+
|APPLICATION_ID |NUMBER |22 |N |
|ATTRIBUTE_NAME |VARCHAR2 |1020 |N |
|ATTRIBUTE_VALUE|CLOB |4000 |Y |
+---------------+---------+-----------+--------+
For MSSQL
+---------------+---------+-----------+-----------+
|COLUMN_NAME |DATA_TYPE|DATA_LENGTH|IS_NULLABLE|
+---------------+---------+-----------+-----------+
|application_id |bigint |null |NO |
|attribute_name |nvarchar |255 |NO |
|attribute_value|nvarchar |-1 |YES |
+---------------+---------+-----------+-----------+
By default, the cwd_application_attribute
table at the source database should contain the following rows. The application_id
may differ across environments, so it should not be altered to match the example below—leave it as is. However, the other two columns in these rows should have the specified values. If there are more than two rows in the cwd_application_attribute
table, please reach out to Atlassian support before making change.
+--------------+----------------------+---------------+
|application_id|attribute_name |attribute_value|
+--------------+----------------------+---------------+
|1 |aggregateMemberships |true |
|1 |atlassian_sha1_applied|true |
+--------------+----------------------+---------------+
Was this helpful?