4.x.x has some data structure changes that cannot be automatically upgraded from 2.x.x. Once you have upgraded your installation to 4.x.x, please run the following scripts to make your data fully compatible with 4.x.x First connect to your SimpleLogin container shell: ```bash docker exec -it sl-app python shell.py ``` Then copy and run this below script: ```python from app.extensions import db from app.models import AliasUsedOn, Contact, EmailLog for auo in AliasUsedOn.query.all(): auo.user_id = auo.alias.user_id db.session.commit() for contact in Contact.query.all(): contact.user_id = contact.alias.user_id db.session.commit() for email_log in EmailLog.query.all(): email_log.user_id = email_log.contact.user_id db.session.commit() ``` Please also update `/etc/postfix/pgsql-relay-domains.cf` to the following. Make sure to replace `mydomain.com` by your actual domain. ``` # postgres config hosts = localhost user = myuser password = mypassword dbname = simplelogin query = SELECT domain FROM custom_domain WHERE domain='%s' AND verified=true UNION SELECT domain FROM public_domain WHERE domain='%s' UNION SELECT '%s' WHERE '%s' = 'mydomain.com' LIMIT 1; ``` and `/etc/postfix/pgsql-transport-maps.cf` to ``` # postgres config hosts = localhost user = myuser password = mypassword dbname = simplelogin # forward to smtp:127.0.0.1:20381 for custom domain AND email domain query = SELECT 'smtp:127.0.0.1:20381' FROM custom_domain WHERE domain = '%s' AND verified=true UNION SELECT 'smtp:127.0.0.1:20381' FROM public_domain WHERE domain = '%s' UNION SELECT 'smtp:127.0.0.1:20381' WHERE '%s' = 'mydomain.com' LIMIT 1; ```
2.1.0 comes with PGP support. If you use PGP, please follow these steps to enable this feature: 1) In your home directory (where `dkim.key` is located), create directory to store SimpleLogin data ```bash mkdir sl mkdir sl/pgp # to store PGP key mkdir sl/db # to store database ``` 2) Then add this line to your config simplelogin.env file ``` GNUPGHOME=/sl/pgp # where to store PGP keys ``` Now you can follow the usual steps to upgrade SimpleLogin.
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() ```