Can't complete migration from H2 to Postgres

Hi I'm trying to migrate my H2 application database to Postgres but the process errors out with

Command failed with exception: ERROR Clearing default entries created by Liquibase migrations...: ERROR Temporarily disabling DB constraints...: ERROR: relation "buckets" does not exist

I'm not sure where it's getting "buckets" from but I'd love to find it and remove it so I can move on. I've tried limiting Metabase's access on my target database to only the "public" schema which only has a single view in it. I have also tried both the Sync database schema now and Re-scan field values now buttons to no avail.

Any help here would be greatly appreciated!

P.S. I've made a pretty helpful script to do the migration for a docker container. It will copy the H2 out of the current "metabase" container to the host, and spin up another metabase container, mount the H2 file, and run the migration command on it. When it's done it will auto remove the new container for you. It's basically what is stated in the docs but sums it up into a quick 2 liner.

docker cp metabase:/metabase.db/metabase.db.mv.db ./metabase-backup
docker run --rm --name metabase-migrate -it \
	-v $(pwd)/metabase-backup:/metabase-backup \
	-e MB_DB_TYPE=postgres \
	-e MB_DB_CONNECTION_URI=postgresql://postgres:<password>@<postgreshost>:5432/postgres \
	--entrypoint '/bin/sh' \
	metabase/metabase \
	-c 'java -jar /app/metabase.jar load-from-h2 /metabase-backup/metabase.db'

Hi @lukep
You need to have Metabase in an empty database. I don't know what "buckets" is, but it's not something included in Metabase, so it's probably something that already exists in your database.
https://www.metabase.com/docs/latest/installation-and-operation/migrating-from-h2

Your connection string is not correct:
https://www.metabase.com/docs/latest/configuring-metabase/environment-variables#mb_db_connection_uri

1 Like

Thank you @flamber - it looks like the "buckets" was in a private schema named "storage". Not sure why Metabase cared about it though since it only had access to the "public" schema. Thanks for your help.