update upgrade.md to its latest stage
This commit is contained in:
parent
77ffa2e35b
commit
737bc7d774
|
@ -2,7 +2,57 @@ Upgrading SimpleLogin usually consists of simply pulling the latest version, sto
|
||||||
|
|
||||||
No emails or any data is lost in the upgrade process. The same process is by the way used by the SimpleLogin SaaS version which is deployed several times per day.
|
No emails or any data is lost in the upgrade process. The same process is by the way used by the SimpleLogin SaaS version which is deployed several times per day.
|
||||||
|
|
||||||
Sometimes upgrading to a major version might require running a manual migration. This is for example the case when upgrading to 2.0.0.
|
Sometimes upgrading to a major version might require running a manual migration. This is for example the case when upgrading to 2.0.0. In this case please follow the corresponding migration first before running these scripts.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Upgrade to 2.0.0</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
2.0.0 comes with mailbox feature that requires running a script that puts all existing users to "full-mailbox" mode.
|
||||||
|
|
||||||
|
1) First please make sure to upgrade to 1.0.5 which is the latest version before 2.0.0.
|
||||||
|
|
||||||
|
2) Then connect to your SimpleLogin container shell:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec -it sl-app python shell.py
|
||||||
|
```
|
||||||
|
|
||||||
|
3) Finally copy and run this below script:
|
||||||
|
|
||||||
|
```python
|
||||||
|
"""This ad-hoc script is to be run when upgrading from 1.0.5 to 2.0.0
|
||||||
|
"""
|
||||||
|
from app.extensions import db
|
||||||
|
from app.log import LOG
|
||||||
|
from app.models import Mailbox, Alias, 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 Alias.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()
|
||||||
|
```
|
||||||
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pull the latest version
|
# Pull the latest version
|
||||||
|
@ -45,49 +95,3 @@ sudo docker run -d \
|
||||||
--network="sl-network" \
|
--network="sl-network" \
|
||||||
simplelogin/app:2.0.0 python email_handler.py
|
simplelogin/app:2.0.0 python email_handler.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Upgrade to 2.0.0 from 1.0.5
|
|
||||||
|
|
||||||
2.0.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 2.0.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()
|
|
||||||
```
|
|
Loading…
Reference in New Issue