Bitbucket Data Center fails to migrate MySQL database

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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 Server and 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.

Environment

Bitbucket Server and Data Center.

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
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).
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. Download the MySQL Connector/J JDBC driver 5.1.x version from the download site (archive).

  3. Expand the downloaded zip/tar.gz file.
  4. Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to your <Bitbucket home directory>/lib directory (for Bitbucket Server 2.1 or later).
  5. Stop, and then restart Bitbucket Server. See Start and stop Bitbucket.


Last modified on May 13, 2024

Was this helpful?

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