Database H2 to PostgreSQL migration

Hi,

I follow the instructions to migrate the database from native H2 to PostgreSQL here. I host Metabase through Docker on an AWS EC2 instance and a PostgreSQL instance on AWS RDS. When I run the command on step 4, I get the error trace below. I already added the rules security rules to port 5432 on the default security group and can connect outside the EC2 instance using an IDE—however, the migration jar file still complains as logged below. May you help me understand its sorrows?

clojure.lang.ExceptionInfo: ERROR Set up h2 source database and run migrations...: The database is read only; SQL statement:
UPDATE DATABASECHANGELOG SET FILENAME = ? [90097-197] {}
Caused by: org.h2.jdbc.JdbcBatchUpdateException: The database is read only; SQL statement:
UPDATE DATABASECHANGELOG SET FILENAME = ? [90097-197] 

Hi @brunolnetto
It says that the H2 file is read-only, so change the permissions of the file.
Without seeing all the commands you input, or knowing your current setup, then it's difficult to tell what you are doing to end up in this situation.

I follow the instructions on the website precisely. As an exercise for yourself, host a docker instance locally and migrate it. The steps I follow are:

  1. Check DB connection (status: ok);
  2. Run command docker cp metabase:/metabase.db/metabase.db.mv.db ./ to backup the database
  3. Change file permission by command run chown +x metabase.db.mv.db;
  4. Stop metabase container with command docker stop METABASE_CONTAINER_ID
  5. Download jar file version Metabase v0.44.4;
  6. Run commands on step 4

This is where I get stuck.

@brunolnetto What is chown +x metabase.db.mv.db supposed to do?

Hehe. It should change file ownership.

sudo chmod 777 metabase.db.mv.db

I used the command below, and stumble upon a further error

ERROR Testing if target h2 database is already populated...: Target DB is already populated! {}

@brunolnetto Try reading the error it is returning. It says that you are now pointing to a H2 instead of Postgres, and that H2 is already setup. Seems like you have forgotten to set the environment variable pointing to the Postgres.

Reading is hard. I thank you, wizard Flamber. :-). May I return futurely for further lectures?

2 posts were split to a new topic: Migrating away from H2