Metabase migration from H2 to mysql fails to load

Dear all,

I’m lost here, hoping to get this solved for.
Thanks in advance!!

Situation:

  • We had Metabase running on h2 for a couple of years now.

  • Now we want to migrate from h2 to mysql production.

  • Still running on version 0.39.0

  • Tried to migrate with the following command with all the details:

java -DMB_DB_TYPE=mysql -DMB_DB_CONNECTION_URI="jdbc:mysql://:3306/metabase?user=&password=" -jar metabase.jar load-from-h2 metabase.db

  • But getting multiple errors and some are related to queries that are in the metabase.jar file which are not getting executed successfully so the migration is failing

2023-05-03 06:36:11,807 WARN metabase.util :: auto-retry metabase.db.liquibase$migrate_up_if_needed_BANG_$fn__34872@6a38e577: Migration failed for change set migrations/000_migrations.yaml::42::camsaul:
Reason: liquibase.exception.DatabaseException: (conn=13) Can't DROP 'fk_queryexecution_ref_query_id'; check that column/key exists [Failed SQL: ALTER TABLE metabase.query_queryexecution DROP FOREIGN KEY fk_queryexecution_ref_query_id]
2023-05-03 06:36:11,921 WARN changelog.DatabaseChangeLog :: modifyDataType will lose primary key/autoincrement/not null settings for mysql. Use and re-specify all configuration if this is the case
2023-05-03 06:36:11,922 WARN changelog.DatabaseChangeLog :: modifyDataType will lose primary key/autoincrement/not null settings for mysql. Use and re-specify all configuration if this is the case
2023-05-03 06:36:11,922 WARN changelog.DatabaseChangeLog :: modifyDataType will lose primary key/autoincrement/not null settings for mysql. Use and re-specify all configuration if this is the case
2023-05-03 06:36:11,923 WARN changelog.DatabaseChangeLog :: modifyDataType will lose primary key/autoincrement/not null settings for mysql. Use and re-specify all configuration if this is the case
2023-05-03 06:36:11,924 WARN changelog.DatabaseChangeLog :: modifyDataType will lose primary key/autoincrement/not null settings for mysql. Use and re-specify all configuration if this is the case
2023-05-03 06:36:11,924 WARN changelog.DatabaseChangeLog :: modifyDataType will lose primary key/autoincrement/not null settings for mysql. Use and re-specify all configuration if this is the case
2023-05-03 06:36:11,938 ERROR changelog.ChangeSet :: Change Set migrations/000_migrations.yaml::42::camsaul failed. Error: (conn=13) Can't DROP 'fk_queryexecution_ref_query_id'; check that column/key exists [Failed SQL: ALTER TABLE metabase.query_queryexecution DROP FOREIGN KEY fk_queryexecution_ref_query_id]
2023-05-03 06:36:11,961 ERROR cmd.copy :: [FAIL]

clojure.lang.ExceptionInfo: ERROR Set up mysql target database and run migrations... {}
at metabase.cmd.copy$do_step$fn__76495.invoke(copy.clj:33)
at metabase.cmd.copy$do_step.invokeStatic(copy.clj:29)
at metabase.cmd.copy$do_step.invoke(copy.clj:27)
at metabase.cmd.copy$fn__76656$copy_BANG___76661$fn__76662.invoke(copy.clj:268)
at metabase.cmd.copy$fn__76656$copy_BANG___76661.invoke(copy.clj:256)
at metabase.cmd.load_from_h2$load_from_h2_BANG_.invokeStatic(load_from_h2.clj:35)
at metabase.cmd.load_from_h2$load_from_h2_BANG_.invoke(load_from_h2.clj:25)
at clojure.lang.Var.invoke(Var.java:384)
at metabase.cmd$load_from_h2.invokeStatic(cmd.clj:45)
at metabase.cmd$load_from_h2.invoke(cmd.clj:39)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:665)
at clojure.core$apply.invoke(core.clj:660)
at metabase.cmd$run_cmd$fn__76159.invoke(cmd.clj:191)
at metabase.cmd$run_cmd.invokeStatic(cmd.clj:191)
at metabase.cmd$run_cmd.invoke(cmd.clj:187)
at clojure.lang.Var.invoke(Var.java:388)
at metabase.core$run_cmd.invokeStatic(core.clj:149)
at metabase.core$run_cmd.invoke(core.clj:147)
at metabase.core$_main.invokeStatic(core.clj:171)
at metabase.core$_main.doInvoke(core.clj:166)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at metabase.core.main(Unknown Source)

  • Havent found any article online to solve for this...

Are you using the 39 jar to try this?