What I Learned Migrating Metabase to Postgres

Since 2022, I’ve maintained a deployment of Metabase for hobby projects. It’s been a key part of learning new skills and showcasing projects.

Over the last 3 years, my Metabase deployment has stayed simple - utilizing the default H2 database that ships with the product. Even though the documentation recommends moving off H2 for stability, I stuck with it while I learned the tool. If felt like the right time to move to the recommended database before my portfolio was at risk.

I knew I would need to learn new skills like working with firewalls, ports, and postgres.

Juggling Servers with SSH

My previous experience with SSH has been simple, connect to a single server and update software packages and files. This time, I was trying to integrate my Metabase server and the new Postgres server so I had multiple ssh windows open. Juggling these windows, keeping in mind where I was working, and finding the right way to organize the windows on my display took some trial and error. It feels good to no longer need to constantly reference common linux terminal commands and I’m starting to get more confident with some more advanced ones.

Terminal windows

Losing My Access (and Fixing It)

A new challenge for me was handling the integration, communication, and security between servers. Since my Metabase server needed to communicate with Postgres, I needed to configure the firewall and open the right ports.

At one point, I was feeling awesome and saved my ufw configuration and completely lost my SSH connection. Luckily, Digital Ocean has a recovery console and I was able to disable the firewall and edit the config to open port 22 - restoring my ssh access. These unexpected bumps in the road are great learning moments and it was exciting to find a solution.

Browser Troubles

Eventually, I finished all the steps to migrate my Metabase app database to Postgres. Success! However when I navigated to my Metabase app, I saw errors where the sidebar navigation panel should be. After hours of migration work, I didn’t have another round of troubleshooting in me. I assumed I had missed a step and something didn’t get transferred to my new database.

Error messages and redirects

The next day, I opened Metabase on another PC and everything looked great! A bit surprised, but happy, I figured some setting hadn’t propagated through to the front-end the previous night. I tried again on my primary PC and still had the missing navigation menus. Originally, I assumed something went wrong with the migration, however the evidence now suggested the issue was isolated to Chrome on my primary PC. I discovered that Chrome had cached an HSTS policy I couldn’t delete. This was causing a series of redirects in that menu. Ultimately, the issue was solved with a new Profile on Chrome, and a reminder that sometimes the issue isn’t the migration, it’s the browser.

Learning with ChatGPT

This was the first project I used ChatGPT extensively to ask questions and learn from. I found the step-by-step instructions for isolating and solving a problem very helpful. The guidance on common steps like setting up postgres, firewalls, and the proxy was quite good. I found it less helpful when we got into areas that were more unique to my deployment of Metabase. ChatGPT kept trying to give me direction for a Metabase deployment using Docker so I gave gentle reminders and pushed it back on course. I was also able to feed ChatGPT error messages and even screenshots of problems and it would diagnose the issues and give some guidance.

Troubleshooting with ChatGPT

As a beginner to some of this deployment work, I wanted more education along the way, so I was consistently asking ChatGPT to provide more detail around why I was entering a command and what certain options did. I don’t want to blindly enter commands into the terminal just to get the job done.

Overall, ChatGPT was a great resource for this project that provided custom documentation tailored to my need while also giving me the ability to drive “stick shift” and run the commands myself.