ERROR Testing if target postgres database is already populated

Hello All.

I am trying to migrate my local metabase to heroku.

I followed this article https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html and configured my enivroment variables as follows:

And the above data is from the heroku metabase instance i created using this link.

And here is a screenshot from my heroku instance credentials.

They should be matching.

When I run java -jar metabase.jar load-from-h2 metabase.db command I get the following exception stating that the target database is modified:

2021-07-31 16:17:48,008 INFO cmd.copy :: Testing if target postgres database is already populated...
2021-07-31 16:17:48,866 ERROR cmd.copy :: [FAIL]

clojure.lang.ExceptionInfo: ERROR Testing if target postgres database is already populated... {}
        at metabase.cmd.copy$do_step$fn__77870.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__78031$copy_BANG___78036$fn__78037.invoke(copy.clj:272)
        at metabase.cmd.copy$fn__78031$copy_BANG___78036.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__77588.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:141)
        at metabase.core$run_cmd.invoke(core.clj:139)
        at metabase.core$_main.invokeStatic(core.clj:163)
        at metabase.core$_main.doInvoke(core.clj:158)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at metabase.core.main(Unknown Source)
Caused by: clojure.lang.ExceptionInfo: Target DB is already populated! {}
        at metabase.cmd.copy$assert_db_empty.invokeStatic(copy.clj:158)
        at metabase.cmd.copy$assert_db_empty.invoke(copy.clj:151)
        at metabase.cmd.copy$fn__78031$copy_BANG___78036$fn__78037$fn__78042.invoke(copy.clj:273)
        at metabase.cmd.copy$do_step$fn__77870.invoke(copy.clj:30)
        ... 23 more
Command failed with exception: ERROR Testing if target postgres database is already populated...

But this should be a clean instance as I didn't even create the starting account.

Thank you in advance.

Hi @Raamyy
Since you have created an instance on Heroku, then it of course creates data - otherwise it would not function for everyone else.
In your case, you have to shutdown the Heroku instance, connect to the Postgres application database and remove all tables, then you can migrate from your local instance, and then you can start the Heroku instance, which will then be using your newly migrated data.

1 Like

Yup I got it now and it is up and running!

Thank you @flamber for your help and clarifications.