Infrastructure Migration

Episode #374 by Teacher's Avatar David Kimura


For various reasons, we may decide to move our services off of one platform onto another. This could be due to pricing, uptime or other reasons. In this episode, we look at migrating a Ruby on Rails application and database from Heroku to Fly.
rails infrastructure database migration 14:09

Resources -
Fly's Migrate from Heroku -

This episode is sponsored by Honeybadger


# Terminal
brew install flyctl
flyctl auth login
fly launch
fly deploy

fly open

fly logs
fly ssh console -C "/app/bin/rails console"

heroku config -s
fly secrets list
fly secrets set HEROKU_DATABASE_URL=$(heroku config:get DATABASE_URL)

heroku maintenance:on --app drexample
heroku maintenance:off --app drexample
fly ssh console

# Dockerfile

RUN curl | bash
ENV VOLTA_HOME /root/.volta
ENV PATH $VOLTA_HOME/bin:/usr/local/bin:$PATH
RUN volta install node@${NODE_VERSION} yarn@${YARN_VERSION}

# Fly Rails App Container Terminal
sh -c 'echo "deb bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
curl | gpg --dearmor | tee /etc/apt/trusted.gpg.d/ >/dev/null
apt update
apt install postgresql-14 -y

pg_dump -Fc --no-acl --no-owner -d $HEROKU_DATABASE_URL | pg_restore --verbose --clean --no-acl --no-owner -d $DATABASE_URL