Updating mastodon (v3.5.3 to v4.0.1)

Updating mastodon (v3.5.3 to v4.0.1)
Photo by Markus Winkler / Unsplash
⚠️
This update was a bit problematic because my machine didn't have enough memory (my machine has 1GB) and that same day v4.0.2 came out. Still, this were all the steps I had to perform.

These are the steps to upgrade mastodon from v3.5.3 to v4.0.1. The entire process takes a bit of time since we are updating ruby as well (don't worry this is pain-free). Start by logging in on the machine.

Then login as mastodon.

$ sudo su - mastodon

Navigate to the live directory and fetch the latest version

$ cd live
$ git fetch --tags
$ git checkout v4.0.1

Update ruby and install the missing gems, this takes the most time.

$ rbenv install
$ bundle install
$ yarn install

Now run the pre-deployment database scripts

$ SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate

Once those have completed, exit the limited session (and become root) to restart the mastodon services.

$ exit
$ systemctl restart mastodon-*

Log back in, navigate to live and, precompile the assets (another long wait) and perform the post-deployment database scripts.

$ sudo su - mastodon
$ cd live
$ RAILS_ENV=production bundle exec rails assets:precompile
$ RAILS_ENV=production bundle exec rails db:migrate

And finally logout and restart the mastodon services one more time.

$ exit
$ systemctl restart mastodon-*

And if you want to install mastodon below is a tutorial.

Mastodon server tutorial
A step by step tutorial to create your own mastodon server (including screenshots) on Digital Ocean. It includes the mail server and the S3 bucket for images. A quick note: This tutorial was written for v3.5.3 and minutes after writing it a new version of Mastodon arrives. Preparing
If you haven't installed Mastodon you can follow this tutorial