Bitbucket Data Center fails to migrate MySQL database

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

Bitbucket Data Center fail to perform a database migration while using Database Migration Wizard.

After successfully backing up all the data, the migration fails while trying to insert the data into a new database.

Diagnosis

The Migration Wizard reports an error similar to the ones below:

  • "created date" is of type timestamp without time zone but expression is of type character varying

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Bitbucket could not be migrated to the new database. Some data may have already been written to the new database leaving it in an inconsistent state. You will need to empty or recreate the com.atlassian.stash.internal.maintenance.migration.DatabaseMigrationTask.convertToMigrationException(DatabaseMigrationTask.java:86) com.atlassian.stash.internal.maintenance.migration.DatabaseMigrationTask.run(DatabaseMigrationTask.java:51) com.atlassian.stash.internal.maintenance.DefaultMaintenanceTaskMonitor.run(DefaultMaintenanceTaskMonitor.java:212) Failed to execute change: Inserts data into an existing table; nested exception is org.postgresql.util.PSQLException: ERROR: column "created date" is of type timestamp without time zone but Hint: You will need to rewrite or cast the expression. Position: 120 com.atlassian.stash.internal.backup.liquibase.DefaultLiquibaseDao.insert(DefaulthiquibaseDao.java:307) com.atlassian.stash.internal.backup.liquibase.DatabaseUpdater.onChangesetContent(DatabaseUpdater.java:63) com.atlassian.stash.internal.backup.liquibase.processors.CompositeChangeSetProcessor.onChangesetContent(CompositeChangeSetProcessor.java:34) FRROR - column "created date" is of type timestamp without time zone but expression is of type character varying Hint: You will need to rewrite or cast the expression. Position: 120
  • Conversion failed when converting date and/or time from character string (due to missing the seconds value in the date specified).

1 2 024-05-01 07:29:44,100 ERROR [threadpool:thread-2] <privet-userid> @519CE3x446x26476x0 1aw4cuu xxx.xxx.xxx.xxx "POST /mvc/admin/db/edit HTTP/1.1" c.a.s.i.b.l.DefaultLiquibaseDao Unable to insert into table cwd_group data [id=3482355, group_name=<group a-z>, lower_group_name=<group a-z>, created_date=2019-11-27T17:39:57, updated_date=2019-12-16T16:17, description=קבוצה ללא גלישה החוצה עבור חרדיות, group_type=GROUP, directory_id=3538945, is_active=T, is_local=F, external_id=a0<privet-userid>41d30488c7e476eb9827628] with statement insert into cwd_group (id, group_name, lower_group_name, created_date, updated_date, description, group_type, directory_id, is_active, is_local, external_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2024-05-01 07:29:44,241 ERROR [threadpool:thread-2] <privet-userid> @519CE3x446x26476x0 1aw4cuu xxx.xxx.xxx.xxx "POST /mvc/admin/db/edit HTTP/1.1" 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: Conversion failed when converting date and/or time from character string.

Cause

Bitbucket is not using a supported MySQL JDBC driver. If it uses any other version than 5.1.x the migration would fail.

Solution

Replace the current MySQL JDBC driver with a driver in 5.1.x version.

  1. Delete the current JDBC driver from <Bitbucket home directory>/lib directory. It is usually called mysql-connector-j-version.jar

  2. Check the current JDBC driver from <Bitbucket install directory>/app/WEB-INF/lib directory. If a mysql-connector-j-version.jar is present there, delete it.

  3. Download the MySQL Connector/J JDBC driver 5.1.x version from the download site (archive).

  4. Expand the downloaded zip/tar.gz file.

  5. Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to your <Bitbucket home directory>/lib directory and <Bitbucket install directory>/app/WEB-INF/lib directory (for Bitbucket Server 2.1 or later).

  6. Ensure the file ownership is correct - chown atlbitbucket:atlbitbucketmysql-connector*

  7. Check that no other connector is present in the $BB_INSTALL/app/WEB-INF/lib & $BB_HOME/lib directories

  8. Stop, and then restart Bitbucket Server. See Start and stop Bitbucket.

If a secondary driver exists, Bitbucket might use it to connect to the MySQL database and the error will persist. Only the 5.1.x connector has been confirmed to be working without issues so far. 

Updated on March 20, 2025

Still need help?

The Atlassian Community is here for you.