Error when migrating from H2 to Postgres


I am trying to migrate the application database from H2 to postgres. The image we have used for docker is metabase/ci:circleci-java-11-clj-

I tried following this documentation. I received the following error when I ran the command java -jar metabase.jar load-from-h2 /path/to/metabase.db:

ERROR MESSAGE: Batch entry 79 INSERT INTO metabase_field ( "description", "database_type", "semantic_type", "table_id", "coercion_strategy", "name", "fingerprint_version", "has_field_values", "settings", "caveats", "fk_target_field_id", "updated_at", "custom_position", "effective_type", "active", "nfc_path", "parent_id", "id", "last_analyzed", "position", "visibility_type", "preview_display", "display_name", "database_position", "fingerprint", "created_at", "base_type", "points_of_interest" ) VALUES ( NULL, 'java.lang.String', 'type/URL', 6721, NULL, 'EDIT_LINK', 5, 'auto-list', NULL, NULL, NULL, '2021-11-13 08:30:09.477+00', 0, 'type/Text', 'TRUE', NULL, NULL, 50467, '2021-11-07 13:24:15.043+00', 66, 'normal', 'TRUE', 'Edit Link', 37, '{"global":{"distinct-count":3,"nil%":0.9998},"type":{"type/Text":{"percent-json":0.0,"percent-url":2.0E-4,"percent-email":0.0,"percent-state":0.0,"average-length":0.0098}}}', '2021-11-07 13:21:07.239+00', 'type/Text', NULL ) was aborted: ERROR: duplicate key value violates unique constraint "idx_uniq_field_table_id_parent_id_name_2col"

To fix this, ran the two commands below on the target database (remove the unique constraint on the stated index), and then tried the migration again. This time, it was successful.

  1. drop index idx_uniq_field_table_id_parent_id_name_2col;
  2. create index idx_uniq_field_table_id_parent_id_name_2col
    on metabase_field (table_id, name)
    where (parent_id IS NULL);

Now when I try to run Metabase via docker-compose with the appropriate env variables, I get the below error stating that checksums validation has failed.

Can you please help in resolving this?

Hi @Parth
I don't understand the Docker image you are referring to. That is not a release, but a development image used for building Metabase.

Which version of Metabase are you currently using? Post "Diagnostic Info" from Admin > Troubleshooting.

You need to run the same version of Metabase during migration as noted in the documentation:

The constraint issue was causing by a bad driver from what I can tell. There's an issue open about it:

Hi @flamber,
Thanks for your reply.

I have copied the same jar file that is being run in the current metabase container. It should be of the same version, correct? Also, I did go through the issue link you shared and followed kind of similar steps to resolve the migration issue. After doing that the migration was successful.

Please find below the Diagnostic Info as requested.

"browser-info": {
"language": "en-GB",
"platform": "MacIntel",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36",
"vendor": "Google Inc."
"system-info": {
"file.encoding": "UTF-8",
"": "OpenJDK Runtime Environment",
"java.runtime.version": "",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "",
"java.version": "",
"": "OpenJDK 64-Bit Server VM",
"java.vm.version": "",
"": "Linux",
"os.version": "5.15.0-1015-aws",
"user.language": "en",
"user.timezone": "GMT"
"metabase-info": {
"databases": [
"hosting-env": "unknown",
"application-database": "h2",
"application-database-details": {
"database": {
"name": "H2",
"version": "1.4.197 (2018-03-18)"
"jdbc-driver": {
"name": "H2 JDBC Driver",
"version": "1.4.197 (2018-03-18)"
"run-mode": "prod",
"version": {
"date": "2022-04-15",
"tag": "vUNKNOWN",
"branch": "master",
"hash": "8296d76"
"settings": {
"report-timezone": null

@Parth The JAR file should be the same, but I have no idea which build you are using. Guess it's caused by something in your custom build. Difficult to say. Basing of master is absolutely not recommended.

But just go and change the migration changeset checksums as listed during the failed startup.
Look in the Postgres application database databasechangelog.md5sum