From 361baff3263c0d5e3663c11d2a48055d08862a2b Mon Sep 17 00:00:00 2001 From: Son NK Date: Fri, 13 Mar 2020 00:14:41 +0100 Subject: [PATCH] add how to upgrade from 1.0.5 to 1.1.0 --- CHANGELOG | 3 +++ README.md | 1 + docs/upgrade.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 docs/upgrade.md diff --git a/CHANGELOG b/CHANGELOG index f3c6c605..405eb6aa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +Support PGP + +## [1.1.0] - 2020-03-13 Support multiple Mailboxes ## [1.0.5] - 2020-02-24 diff --git a/README.md b/README.md index 9edf7845..a90b0c57 100644 --- a/README.md +++ b/README.md @@ -541,6 +541,7 @@ Below are pointers to different topics: - [UFW - uncomplicated firewall](docs/ufw.md) - [SES - Amazon Simple Email Service](docs/ses.md) +- [Upgrade existing SimpleLogin installation][docs/upgrade.md] ## Contributing diff --git a/docs/upgrade.md b/docs/upgrade.md new file mode 100644 index 00000000..04115019 --- /dev/null +++ b/docs/upgrade.md @@ -0,0 +1,44 @@ +# Upgrade to 1.1.0 from 1.0.5 + +1.1.0 comes with mailbox feature that requires running a script that puts all existing users to "full-mailbox" mode. + +Please connect to your SimpleLogin container and runs this script: + +First run shell.py: + +```bash +docker exec -it sl-app python shell.py +``` + +Then copy and run this below script: + +```python +"""This ad-hoc script is to be run when upgrading from 1.0.5 to 1.1.0 +""" +from app.extensions import db +from app.log import LOG +from app.models import Mailbox, GenEmail, User + +for user in User.query.all(): + if user.default_mailbox_id: + # already run the migration on this user + continue + + # create a default mailbox + default_mb = Mailbox.get_by(user_id=user.id, email=user.email) + if not default_mb: + LOG.d("create default mailbox for user %s", user) + default_mb = Mailbox.create(user_id=user.id, email=user.email, verified=True) + db.session.commit() + + # assign existing alias to this mailbox + for gen_email in GenEmail.query.filter_by(user_id=user.id): + if not gen_email.mailbox_id: + LOG.d("Set alias %s mailbox to default mailbox", gen_email) + gen_email.mailbox_id = default_mb.id + + # finally set user to full_mailbox + user.full_mailbox = True + user.default_mailbox_id = default_mb.id + db.session.commit() +``` \ No newline at end of file