1.0 Upgrade Instructions
Preparations
- Make sure you have working backups, and test that they can be restored (e.g. to your local computer)
- Tune your database for the specific hardware to make the migrations run faster
- Before upgrading the production server, you can test if the migration works correctly and see how long it takes. For this take the backup from above and load it into a test database. Then run the latest 1.0 release with that database. If the test upgrade fails, open an issue.
- On lemmy.ml the migrations take about 24 hours, during which the site will be inaccessible. Post an announcement about the planned upgrade time and use “Feature in Local” so that all users see it.
- If you use Ansible, specify the version explicitly in
hostsfile, for examplelemmy_version=1.0.0-beta.1.
Faster Upgrading
The upgrade is slow because most of the existing SQL tables are rewritten into different formats. If you don’t care too much about historical posts, you can clear out some data to reduce the DB size and speed up the migration.
Here are some sample queries. Be careful, they will even delete remote posts in local communities, and posts that were upvoted or saved by local users. Best try on a local copy of the production query first, and modify the query to add extra filters.
Delete all remote posts without comments:
delete from post using post_aggregates where post.id = post_aggregates.post_id and local = false and comments = 0 and post.published < now() - '1 year'::interval;
Delete all remote posts and comments which are older than one month.
delete from post where published < now() - '1 month'::interval and local = false;
delete from comment where published < now() - '1 month'::interval and local = false;
Run the Upgrade
- If you run with multiple Lemmy backend processes as described in horizontal scaling, make sure only one is active while running migrations.
- Adjust lemmy-ui environment variables. The important ones are:
- LEMMY_UI_BACKEND_INTERNAL=http://lemmy:8536
- LEMMY_UI_BACKEND=https://voyager.lemmy.ml
- Adjust lemmy.hjson config variables.
- Instead of separate database fields
host,passwordetc, there is a singleconnectionurl - The email section also uses a
connectionurl
- Instead of separate database fields
- Upgrade version names in your
docker-compose.ymlfile (eg replacedessalines/lemmy:0.19.XXwithdessalines/lemmy:1.0.0-beta.1) - Wait for migrations to complete (this may take many hours as noted above)
- Test that the site is working as expected