On Upgrading to v3.4.0 modified mastodon without forking

#建站合集SysAdmin

Context

Nope, the gitlab wasn't set up when the upgrade happened, and the git wasn't forked.

All modifications were directly nanoed on the vps.

Database backing up with postgresql in case something goes wrong

sudo mkdir /opt/PGBACKUPS
sudo chown -R postgres:postgres /opt/PGBACKUPS
sudo su - postgres


pg_dump -U postgres -d mastodon_production > /opt/PGBACKUPS/mastodon_production$(date +%Y-%m-%d_%H_%M_%S).sql 

Copy the backup file to another machine in case the whole vps got fucked up.

Upgrade

Stash the modified files and git checkout.

sudo su - mastodon
cd /home/mastodon/live/
git stash 
git fetch --tags
git checkout v3.4.0

Bundle install and yarn install and compile as instructed in the github upgrade guide.

bundle install
yarn install
cd /home/mastodon/live/
SKIP_POST_DEPLOYMENT_MIGRATIONS=true 
RAILS_ENV=production bundle exec rails db:migrate                                                                                                  RAILS_ENV=production bundle exec rails assets:precompile     

Check if everything works.

If that's the case, git stash apply.

git stash apply stash@{0} 

After resolving all the conflicts, compile.

RAILS_ENV=production bundle exec rails assets:precompile 

then

systemctl restart mastodon-sidekiq
systemctl reload mastodon-web
systemctl restart mastodon-streaming