Git Product home page Git Product logo

gocd-database-migrator's Introduction

Tool for Migrating a GoCD database on version 20.4.0 (or below) to a GoCD 20.5.0 compliant database.

GoCD has made several changes in version v20.5.0 to its database implementation in order to build a more flexible model that allowed integrating GoCD with multiple databases. This application helps to migrate the data from older GoCD database v20.4.0 (or below) to the GoCD v20.5.0 compatible database.

Know more about GoCD support for multiple databases here.

Features:

  • Migrates data from older GoCD database v20.4.0 (or below) to the GoCD v20.5.0 compatible database. This tool helps to upgrade the data from existing GoCD database running on GoCD v20.4.0 (or below) to the GoCD v20.5.0 compatible database.

  • As part of migrating data from a older GoCD v20.4.0 (or below) to the GoCD v20.5.0 database, users can convert/sync data from one database to another. This allows GoCD users to switch from any of the existing database to H2, PostgreSQL or MySQL database.

  • For databases which are already migrated and are GoCD v20.5.0 compliant, this tool can be used to sync data to a new database post the initial migration to GoCD v20.5.0. E.g Sync data from a GoCD v20.5.0 H2 database to a new PostgreSQL database. Verified to work till GoCD v20.8.0.

Supported Databases

  • H2 (1.3.xxx and above)
  • PostgreSQL (9.6 and above)
  • MySQL (8.0)

Installation

1. From The Source:

The GoCD Database Migrator v1.0.0 sources can be obtained from the GitHub Releases. You should get a file named gocd-database-migrator-1.0.0.tgz. After you have downloaded the file, unpack it:

$ gunzip gocd-database-migrator-1.0.0.tgz
$ tar xf gocd-database-migrator-1.0.0.tar

This will create a directory gocd-database-migrator-1.0.0 under the current directory with the GoCD Database Migrator sources. Change into the directory and run ./bin/gocd-database-migrator --help for usage instructions.

Databases migration instructions

Follow detailed instructions in Upgrading to GoCD 20.5.0 document to migrate your database.

Command Arguments:

Argument Description
source-db-url The source database url. Specify the existing GoCD database url.
If none specified, it will default to cruise (this is the H2 database file without the .h2.db extension) in the current directory. See Example database connection URLs.
source-db-driver-class The source database driver class.
If none specified, it will choose the appropriate driver class based on the specified --source-db-url. See Default database driver class.
source-db-user The username of the source database.
source-db-password The password of the source database.
target-db-url The target database url. Specify the newly created database url where the data will be copied. See Example database connection URLs.
target-db-driver-class The target database driver class.
If none specified, it will choose the appropriate driver class based on the specified --target-db-url. See Default database driver class.
target-db-user The username of the target database.
target-db-password The password of the target database.
batch-size The number of records to SELECT from the source database to INSERT into the target database in each batch.
Default: 100000
output The output SQL file. Specify .gz extension to enable gzip compression.
insert Perform INSERT into target database.
Default: false
progress Show the progress of the export operation.
Default: false
threads Number of import threads.
Default: the number of processor cores (up to 8)
export-timeout Number of seconds to allow data to be exported from source to target database before timing out.
Default: 1800 secs (30 minutes)

Example database connection URLs:

Some example database URLs that the tool understands:

  • H2 URL: jdbc:h2:/path/to/cruise (this is the H2 database path without the .h2.db extension)
  • PostgreSQL URL: jdbc:postgresql://localhost:5432/gocd
  • MySQL URL: jdbc:mysql://localhost:3306/gocd

Default database driver class:

When no database driver is specified for the source database (--source-db-driver-class) or the target database (--target-db-driver-class), based on the specified database url, the tool will choose the appropriate driver class.

  • For H2 database urls (starting with jdbc:h2:), database driver is set to org.h2.Driver.
  • For PostgreSQL database urls (starting with jdbc:postgresql:), database driver is set to org.postgresql.Driver.
  • For MySQL database urls (starting with jdbc:mysql:), database driver is set to com.mysql.cj.jdbc.Driver.

Example usages:

  • Migrate from an older version of GoCD (which uses an old H2 version) to a newer version that uses a new H2 version.

    ./bin/gocd-database-migrator \
            --insert \
            --progress \
            --source-db-url='jdbc:h2:/godata/backup/db/h2db/cruise' \
            --source-db-user='sa' \
            --source-db-password='sa-password' \
            --target-db-url='jdbc:h2:/var/lib/gocd/new-database/db/h2db/cruise' \
            --target-db-user='target-sa' \
            --target-db-password='target-sa-password'
  • Sync data from H2 to PostgreSQL

    ./bin/gocd-database-migrator \
            --insert \
            --progress \
            --source-db-url='jdbc:h2:/godata/backup/db/h2db/cruise' \
            --source-db-user='sa' \
            --source-db-password='sa-password' \
            --target-db-url='jdbc:postgresql://localhost:5432/cruise' \
            --target-db-user='postgres' \
            --target-db-password='postgres-password'

License

Copyright 2022 Thoughtworks, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

gocd-database-migrator's People

Contributors

arvindsv avatar chadlwilson avatar dependabot[bot] avatar ganeshspatil avatar gradle-update-robot avatar ketan avatar kritika-singh3 avatar maheshp avatar marques-work avatar rezaetezal avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gocd-database-migrator's Issues

Db migrator fails for default username

WHile running the db migrator for h2db to postgress db I get the below error.
I have verified the target database connection details using psql from the same machine as I am running the migrator from.
I am running below command and the output is listed. Not sure where is go user comming from

./bin/gocd-database-migrator --insert --progress --source-db-url='jdbc:h2:/godata/db/h2db/cruise' --source-db-user='sa' --source-db-password=''
 --target-db-url='jdbc:postgresql://gocd-database-1.eu-central-1.rds.amazonaws.com:5432/gocd'--target-db-user='xxxx' --target-db-password='xxxx'
INFO: No `--source-db-driver-class` is specified. Setting `--source-db-driver-class='org.h2.Driver'`.
INFO: No `--target-db-driver-class` specified. Setting `--target-db-driver-class='org.postgresql.Driver'`.
2021-01-25 13:04:33,331 INFO  [main] DbSync:77 - Using dialect H2 for source database.
2021-01-25 13:04:33,870 ERROR [main] DbSync:103 - null
java.sql.SQLException: Cannot create PoolableConnectionFactory (FATAL: password authentication failed for user "go")
	at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:669)
	at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:544)
	at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:753)
	at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:95)
	at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:78)
	at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "go"
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525)
	at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
	at org.postgresql.Driver.makeConnection(Driver.java:459)
	at org.postgresql.Driver.connect(Driver.java:261)
	at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:55)
	at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:355)
	at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:115)
	at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:665)
	... 5 common frames omitted
java.lang.RuntimeException: java.sql.SQLException: Cannot create PoolableConnectionFactory (FATAL: password authentication failed for user "go")
	at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:104)
	at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:78)
	at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)
Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (FATAL: password authentication failed for user "go")
	at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:669)
	at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:544)
	at org.apache.commons.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:753)
	at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:95)
	... 2 more
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "go"
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525)
	at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
	at org.postgresql.Driver.makeConnection(Driver.java:459)
	at org.postgresql.Driver.connect(Driver.java:261)
	at org.apache.commons.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:55)
	at org.apache.commons.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:355)
	at org.apache.commons.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:115)
	at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:665)
	... 5 more

Cannot upgrade H2 database from v19.2.0 to v21.2.0

We are using GoCD (Ubuntu 18.04) backed by a H2 database and want to upgrade to v21.2.0 (Ubuntu 18.04)

The migration tool failed to process the database:

bash-5.0# ./bin/gocd-database-migrator \
>   --insert \
>   --progress \
>   --source-db-url='jdbc:h2:/godata/db/h2db/cruisegocd19' \
>   --source-db-user='…' \
>   --source-db-password='…' \
>   --target-db-url='jdbc:h2:/godata/db/h2db/cruise' \
>   --target-db-user='…' \
>   --target-db-password='…'
INFO: No `--source-db-driver-class` is specified. Setting `--source-db-driver-class='org.h2.Driver'`.
INFO: No `--target-db-driver-class` specified. Setting `--target-db-driver-class='org.h2.Driver'`.
2021-03-26 17:18:41,036 INFO  [main] DbSync:77 - Using dialect H2 for source database.
2021-03-26 17:18:41,091 INFO  [main] DbSync:78 - Using dialect H2 for target database.
Reading change scripts from directory /home/go/gocd-database-migrator-1.0.0/h2deltas...
dbdeploy v2.11
Changes currently applied to database:
  1..90, 221001, 230001..230009, 240001, 240002, 300001..300011, 1202001..1202003, 1203002..1203005, 1301001, 1302001, 1303001..1303004, 1304001, 1401001, 1403001, 1403002, 1501001..1501003, 1502001, 1503001, 1503002, 1606001, 1606002, 1607001, 1610001, 1701001, 1702001, 1704001..1704003, 1708001, 1801001..1801007, 1802001, 1802002, 1804001, 1805001, 1807001, 1807002, 1808001, 1808002, 1901001, 1902001..1902008
Scripts available:
  1..90, 221001, 230001..230009, 240001, 240002, 300001..300011, 1202001..1202003, 1203002..1203005, 1301001, 1302001, 1303001..1303004, 1304001, 1401001, 1403001, 1403002, 1501001..1501003, 1502001, 1503001, 1503002, 1606001, 1606002, 1607001, 1610001, 1701001, 1702001, 1704001..1704003, 1708001, 1801001..1801007, 1802001, 1802002, 1804001, 1805001, 1807001, 1807002, 1808001, 1808002, 1901001, 1902001..1902008, 1903001..1903003, 1909001, 1910001..1910006
To be applied:
  1903001..1903003, 1909001, 1910001..1910006
2021-03-26 17:18:41,181 ERROR [main] DbSync:99 - null
org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException: Cannot invoke ""org.h2.index.Index.getRowCountApproximation()"" because ""this.scanIndex"" is null"; SQL statement:


--------------- Fragment begins: #1903001: 1903001_add_status_and_message_to_server_backup.sql ---------------
INSERT INTO changelog (change_number, delta_set, start_dt, applied_by, description) VALUES (1903001, 'DDL', CURRENT_TIMESTAMP, USER(), '1903001_add_status_and_message_to_server_backup.sql'); [50000-200]
…

Is there any plausible explanation to this and most importantly, recovery way so that we can upgrade the database?

Data from H2 not migrated to Postgres

I ran the migrator but it doesn't look like any of the data made it into Postgres. It created the tables and indexes though.

# ls -l /tmp/gocd/db/h2db/cruise.h2.db
-rw-rw-r-- 1 1000 1000 448632832 Feb  3 15:20 /tmp/gocd/db/h2db/cruise.h2.db
# time ./bin/gocd-database-migrator \
--insert \
--progress \
--source-db-url='jdbc:h2:/tmp/gocd/db/h2db/cruise.h2.db' \
--source-db-user='sa' \
--source-db-password='' \
--target-db-url='jdbc:postgresql://localhost:5432/gocd' \
--target-db-user='gocd' \
--target-db-password='password'
INFO: No `--source-db-driver-class` is specified. Setting `--source-db-driver-class='org.h2.Driver'`.
INFO: No `--target-db-driver-class` specified. Setting `--target-db-driver-class='org.postgresql.Driver'`.
2021-02-03 16:54:04,540 INFO  [main] DbSync:77 - Using dialect H2 for source database.
2021-02-03 16:54:04,653 INFO  [main] DbSync:78 - Using dialect POSTGRES for target database.
2021-02-03 16:54:05,060 INFO  [main] DbSync:107 - Initializing database skeleton on target database.
2021-02-03 16:54:08,864 INFO  [main] DbSync:109 - Done initializing database skeleton on target database.
2021-02-03 16:54:08,866 INFO  [main] DbSync:113 - Initializing database views.
2021-02-03 16:54:09,337 INFO  [main] DbSync:115 - Done initializing database views.
2021-02-03 16:54:09,340 INFO  [main] DbSync:120 - Copying database records.
2021-02-03 16:54:09,341 INFO  [main] DbSync:190 - Found tables:

2021-02-03 16:54:09,420 INFO  [main] DbSync:122 - Done copying database records.
2021-02-03 16:54:09,429 INFO  [main] DbSync:127 - Setting sequences for all tables.
2021-02-03 16:54:09,431 INFO  [main] DbSync:129 - Done setting sequences for all tables.
2021-02-03 16:54:09,432 INFO  [main] DbSync:133 - Initializing database indices and constraints on target database. This may take several minutes, depending on the size of the database.
2021-02-03 16:54:10,476 INFO  [main] DbSync:135 - Done initializing database indices and constraints on target database.
2021-02-03 16:54:10,478 INFO  [main] DbSync:144 - Verifying if number of records are identical in source and target.
2021-02-03 16:54:10,479 INFO  [main] DbSync:163 - All good!
2021-02-03 16:54:10,489 INFO  [main] DbSync:181 - Done copying tables!

real	0m7.323s
user	0m11.982s
sys	0m0.496s

Is this the correct username and password for the H2 database? It looks like it may have had trouble opening it but I don't see any errors.

Unset sequence values on converting H2 to Postgres 12

After converting an H2 database to Postgres 12, we were unable to modify materials for pipelines in GoCD. The error message indicated a primary key overlap. An investigation revealed that a sequence ID was too low given the IDs present in the materials table. To fix it, we manually set the sequence ID forward to the maximum row ID on the materials table. Based on an unmodified/fresh database migration, the root cause appears to be that there are certain sequences with no value set during migration.

Evidence of Possible Root Cause:

gocd=> select sequencename from pg_sequences where last_value is null;
             sequencename
---------------------------------------
 accesstoken_id_seq
 agents_id_seq
 jobagentmetadata_id_seq
 materials_id_seq
 notificationfilters_id_seq
 pipelineselections_id_seq
 plugins_id_seq
 stageartifactcleanupprohibited_id_seq
 users_id_seq

Symptoms of Issue (when trying to update a material):

2020-08-18 16:55:12,206 WARN  [128@MessageListener for MaterialUpdateListener] MaterialDatabaseUpdater:127 - [Material Update] Modification check failed for material: URL: [email protected], Branch: updated_branch
org.springframework.dao.DataIntegrityViolationException: could not insert: [com.thoughtworks.go.domain.materials.git.GitMaterialInstance]; SQL [insert into materials (flyweightName, fingerprint, additionalData, url, username, branch, submoduleFolder, type) values (?, ?, ?, ?, ?, ?, ?, 'GitMaterial')]; constraint [materials_pkey]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [com.thoughtworks.go.domain.materials.git.GitMaterialInstance]
...
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "materials_pkey"

gocd=> select last_value from pg_sequences where sequencename = 'materials_id_seq';
 last_value
------------
        113

gocd=> select max(id) from materials;
 max
------
 1305

Fix (for symptom):

gocd=> select setval('materials_id_seq',1305);
 setval
--------
   1305

org.postgresql.util.PSQLException: ERROR: relation "properties" does not exist

Getting the following error while trying to migrate gocd server from H2 database to postgres 9.6:
GoCD version : 20.4.0
Java version: 1.8.0_302

record copy progress 0% [=> ] 160000/16215439 record (0:00:07 / 0:11:44) 22857.1 record/s2021-11-23 10:10:33,834 ERROR [pool-2-thread-1] DbSync:87 - null
org.postgresql.util.PSQLException: ERROR: relation "properties" does not exist
Position: 13
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
at com.thoughtworks.go.dbsync.Util.execute(Util.java:84)
at com.thoughtworks.go.dbsync.Util.executeAndLog(Util.java:61)
at com.thoughtworks.go.dbsync.DbSync.executAndLogInsertStatement(DbSync.java:373)
at com.thoughtworks.go.dbsync.DbSync.dumpTableSQL(DbSync.java:356)
at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:201)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
.
.
.
.
.
record copy progress 40% [=================================================================> ] 6543237/16215439 record (0:11:20 / 0:16:46) 9622.4 record/s^[
2021-11-23 10:21:47,001 INFO [main] DbSync:121 - Done copying database records.
2021-11-23 10:21:47,003 INFO [main] DbSync:126 - Setting sequences for all tables.
2021-11-23 10:21:47,017 ERROR [main] DbSync:87 - null
org.postgresql.util.PSQLException: ERROR: relation "properties" does not exist
Position: 57
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
at com.thoughtworks.go.dbsync.Util.execute(Util.java:84)
at com.thoughtworks.go.dbsync.Util.executeAndLog(Util.java:61)
at com.thoughtworks.go.dbsync.DbSync.resetSequences(DbSync.java:310)
at com.thoughtworks.go.dbsync.DbSync.lambda$export$7(DbSync.java:127)
at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:97)
at com.thoughtworks.go.dbsync.DbSync.lambda$export$11(DbSync.java:125)
at com.thoughtworks.go.dbsync.DbSync.withWriter(DbSync.java:292)
at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:101)
at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)

upgrade of large h2 db fails on 'Timeout trying to lock table "SYS"'

I have a 150gb h2db file. I just upgraded from 18.9 to 20.0.4 with no issues, then ran the database migrator script. It gets maybe aroud 10% into the record copy progress status, then fails with this 'Timeout trying to lock table "SYS"' exception and spits out some REALLY long SQL statement. Googling this error I found that maybe the default LOCK_TIMEOUT is maybe to short, and I tried passing an increased one into the jdbc url but I still get the same issue. I can't tell for certain if the increased LOCK_TIMEOUT is actually being set and used, as I don't know how to dump the current settings while it runs. Any ideas on how to debug this further?

export JAVA_HOME=/opt/java/jdk1.8.0_201/; export PATH="$JAVA_HOME/bin:$PATH"
nohup ./gocd-database-migrator \
--insert \
--progress \
--source-db-url='jdbc:h2:/data/gocd-server-backup/gocdhost/data/gocd-db/db/h2db/cruise;LOCK_TIMEOUT=300000' \
--source-db-user='sa' \
--source-db-password='' \
--target-db-url='jdbc:h2:/data/gocd-server-backup/gocdhost/data/gocd-db/db/h2db/NEWLY_MIGRATED_cruise;LOCK_TIMEOUT=300000' \
--target-db-user='sa' \
--target-db-password='' \
> gocd-database-migrator-1.0.0/gocd_h2db_upgrade.log 2>&1 &

Migrate data from new H2 database to Postgres

As part of migrating to GoCD 20.8.0 from 20.4.0, we had to migrate the DB: https://docs.gocd.org/current/installation/upgrade_to_gocd_20.5.0.html

We chose to migrate to H2 as a temporary solution but we would like to migrate the data to Postgres later on.
The migration process from H2 to H2 went smoothly but the migration from new H2 database to Postgres failed with multiple exceptions (see below):

Is there a plan to support migration from new H2 database to Postgres?

Migrator version: 1.0.0-33.
Java: openjdk version "11.0.7" 2020-04-14

Exceptions
ERROR [pool-2-thread-1] DbSync:203 - null
org.jooq.exception.DataAccessException: SQL [select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ?]; Data conversion error converting "2006001_remove_data_sharing_settings_table"; SQL statement:
select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ? [22018-200]
	at org.jooq_3.13.1.H2.debug(Unknown Source)
	at org.jooq.impl.Tools.translate(Tools.java:2751)
	at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:385)
	at org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:354)
	at org.jooq.impl.SelectImpl.fetch(SelectImpl.java:2690)
	at com.thoughtworks.go.dbsync.DbSync.dumpTableSQL(DbSync.java:341)
	at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:201)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "2006001_remove_data_sharing_settings_table"; SQL statement:
select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ? [22018-200]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:457)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
	at org.h2.message.DbException.get(DbException.java:194)
	at org.h2.value.Value.convertTo(Value.java:875)
	at org.h2.value.Value.convertTo(Value.java:758)
	at org.h2.value.Value.compareWithNull(Value.java:1583)
	at org.h2.engine.Database.compareWithNull(Database.java:427)
	at org.h2.expression.condition.Comparison.compare(Comparison.java:311)
	at org.h2.expression.condition.Comparison.getValue(Comparison.java:256)
	at org.h2.expression.Expression.getBooleanValue(Expression.java:258)
	at org.h2.command.dml.Select.isConditionMet(Select.java:448)
	at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1846)
	at org.h2.result.LazyResult.hasNext(LazyResult.java:101)
	at org.h2.result.LazyResult.next(LazyResult.java:60)
	at org.h2.command.dml.Select.queryFlat(Select.java:737)
	at org.h2.command.dml.Select.queryWithoutCache(Select.java:844)
	at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:201)
	at org.h2.command.dml.Query.query(Query.java:489)
	at org.h2.command.dml.Query.query(Query.java:451)
	at org.h2.command.CommandContainer.query(CommandContainer.java:285)
	at org.h2.command.Command.executeQuery(Command.java:195)
	at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:233)
	at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
	at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
	at org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:209)
	at org.jooq.impl.Tools.executeStatementAndGetFirstResultSet(Tools.java:3956)
	at org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:295)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:371)
	... 7 common frames omitted
Caused by: java.lang.NumberFormatException: For input string: "2006001_remove_data_sharing_settings_table"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Long.parseLong(Long.java:692)
	at java.base/java.lang.Long.parseLong(Long.java:817)
	at org.h2.value.Value.convertToLong(Value.java:1011)
	at org.h2.value.Value.convertTo(Value.java:808)
	... 31 common frames omitted
Exception in thread "pool-2-thread-1" java.lang.RuntimeException: org.jooq.exception.DataAccessException: SQL [select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ?]; Data conversion error converting "2006001_remove_data_sharing_settings_table"; SQL statement:
select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ? [22018-200]
	at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:204)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jooq.exception.DataAccessException: SQL [select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ?]; Data conversion error converting "2006001_remove_data_sharing_settings_table"; SQL statement:
select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ? [22018-200]
	at org.jooq_3.13.1.H2.debug(Unknown Source)
	at org.jooq.impl.Tools.translate(Tools.java:2751)
	at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:385)
	at org.jooq.impl.AbstractResultQuery.fetch(AbstractResultQuery.java:354)
	at org.jooq.impl.SelectImpl.fetch(SelectImpl.java:2690)
	at com.thoughtworks.go.dbsync.DbSync.dumpTableSQL(DbSync.java:341)
	at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:201)
	... 3 more
Caused by: org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "2006001_remove_data_sharing_settings_table"; SQL statement:
select * from DATABASECHANGELOG where id > cast(? as bigint) order by id limit ? [22018-200]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:457)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
	at org.h2.message.DbException.get(DbException.java:194)
	at org.h2.value.Value.convertTo(Value.java:875)
	at org.h2.value.Value.convertTo(Value.java:758)
	at org.h2.value.Value.compareWithNull(Value.java:1583)
	at org.h2.engine.Database.compareWithNull(Database.java:427)
	at org.h2.expression.condition.Comparison.compare(Comparison.java:311)
	at org.h2.expression.condition.Comparison.getValue(Comparison.java:256)
	at org.h2.expression.Expression.getBooleanValue(Expression.java:258)
	at org.h2.command.dml.Select.isConditionMet(Select.java:448)
	at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1846)
	at org.h2.result.LazyResult.hasNext(LazyResult.java:101)
	at org.h2.result.LazyResult.next(LazyResult.java:60)
	at org.h2.command.dml.Select.queryFlat(Select.java:737)
	at org.h2.command.dml.Select.queryWithoutCache(Select.java:844)
	at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:201)
	at org.h2.command.dml.Query.query(Query.java:489)
	at org.h2.command.dml.Query.query(Query.java:451)
	at org.h2.command.CommandContainer.query(CommandContainer.java:285)
	at org.h2.command.Command.executeQuery(Command.java:195)
	at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:233)
	at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
	at org.apache.commons.dbcp2.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:94)
	at org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:209)
	at org.jooq.impl.Tools.executeStatementAndGetFirstResultSet(Tools.java:3956)
	at org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:295)
	at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:371)
	... 7 more
Caused by: java.lang.NumberFormatException: For input string: "2006001_remove_data_sharing_settings_table"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.base/java.lang.Long.parseLong(Long.java:692)
	at java.base/java.lang.Long.parseLong(Long.java:817)
	at org.h2.value.Value.convertToLong(Value.java:1011)
	at org.h2.value.Value.convertTo(Value.java:808)
	... 31 more
ERROR [pool-2-thread-2] DbSync:203 - null
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
	at com.thoughtworks.go.dbsync.DbSync.dumpTableSQL(DbSync.java:354)
	at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:201)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Exception in thread "pool-2-thread-2" java.lang.RuntimeException: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
	at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:204)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')
	at com.thoughtworks.go.dbsync.DbSync.dumpTableSQL(DbSync.java:354)
	at com.thoughtworks.go.dbsync.DbSync.lambda$doExport$13(DbSync.java:201)
	... 3 more
INFO  [main] DbSync:121 - Done copying database records.
INFO  [main] DbSync:126 - Setting sequences for all tables.
ERROR [main] DbSync:87 - null
org.postgresql.util.PSQLException: ERROR: function setval(unknown, text) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 8
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at com.thoughtworks.go.dbsync.Util.execute(Util.java:84)
	at com.thoughtworks.go.dbsync.Util.executeAndLog(Util.java:61)
	at com.thoughtworks.go.dbsync.DbSync.resetSequences(DbSync.java:310)
	at com.thoughtworks.go.dbsync.DbSync.lambda$export$7(DbSync.java:127)
	at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:97)
	at com.thoughtworks.go.dbsync.DbSync.lambda$export$11(DbSync.java:125)
	at com.thoughtworks.go.dbsync.DbSync.withWriter(DbSync.java:292)
	at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:101)
	at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)
2020-10-08 10:37:52,200 ERROR [main] DbSync:99 - null
java.lang.RuntimeException: org.postgresql.util.PSQLException: ERROR: function setval(unknown, text) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 8
	at com.thoughtworks.go.dbsync.Util.execute(Util.java:88)
	at com.thoughtworks.go.dbsync.Util.executeAndLog(Util.java:61)
	at com.thoughtworks.go.dbsync.DbSync.resetSequences(DbSync.java:310)
	at com.thoughtworks.go.dbsync.DbSync.lambda$export$7(DbSync.java:127)
	at com.thoughtworks.go.dbsync.Util.withDataSource(Util.java:97)
	at com.thoughtworks.go.dbsync.DbSync.lambda$export$11(DbSync.java:125)
	at com.thoughtworks.go.dbsync.DbSync.withWriter(DbSync.java:292)
	at com.thoughtworks.go.dbsync.DbSync.export(DbSync.java:101)
	at com.thoughtworks.go.dbsync.cli.Main.main(Main.java:46)
Caused by: org.postgresql.util.PSQLException: ERROR: function setval(unknown, text) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 8
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:310)
	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:296)
	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:273)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:268)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194)
	at com.thoughtworks.go.dbsync.Util.execute(Util.java:84)
	... 8 common frames omitted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.