|
3 | 3 |
|
4 | 4 | Migration guides are here to help you migrate to the latest version of [<MainPlatformName /> Community Edition](../mergince/).
|
5 | 5 |
|
6 |
| -## Migration guide to 2023.2 |
| 6 | +## Migration guide from any previous version to 2023.2 |
7 | 7 |
|
| 8 | +Besides various fixes, enhancements and performance improvements the most notable change recently introduced is the concept of workspaces. For Community Edition it means there is a **common shared workspace (global workspace)** for all users where all projects are stored, instead of having a personal or organisational namespace for projects. |
| 9 | + |
| 10 | +:::tip |
| 11 | +In case you do not need your previous data, we advise to start with [clean deployment](../mergince/#how-to-deploy-mergin-maps-ce) without the need to follow this migration guide. |
| 12 | +::: |
| 13 | + |
| 14 | +**Upgrading to 2023.2** |
| 15 | + |
| 16 | + 1. Synchronise **all your projects and devices** using <MobileAppName /> and <QGISPluginName />. Make sure there are no pending changes. |
| 17 | + |
| 18 | + 2. After synchronisation, all downloaded projects need to be **removed** from all devices using <MobileAppName /> and <QGISPluginName /> |
| 19 | + |
| 20 | + 3. Backup your database ⚠️ |
| 21 | + |
| 22 | +```bash |
| 23 | +$ docker exec mergin-db pg_dump -U postgres -Fc postgres > pg_backup.dump |
| 24 | +``` |
| 25 | + |
| 26 | + 4. Stop all running <MainPlatformName /> services (from project root folder) |
| 27 | +```bash |
| 28 | +$ docker-compose -f docker-compose.yml stop |
| 29 | +``` |
| 30 | + |
| 31 | + 5. Pull the latest changes |
| 32 | +```bash |
| 33 | +$ git pull |
| 34 | +``` |
| 35 | + |
| 36 | + 6. Set environment variables (<GitHubRepo desc=".prod.env" id="MerginMaps/mergin/blob/master/.prod.env" /> file). **Important** ⚠️ |
| 37 | + |
| 38 | +As mentioned earlier, CE operates with one global workspace. We will set it up now. |
| 39 | +Specify its name with the following environment variable: |
| 40 | + |
| 41 | + - `GLOBAL_WORKSPACE=ShinyWorkspace` - name of your workspace. A good fit is a name of your company or team. This value *should not be changed* later. |
| 42 | + |
| 43 | +:::tip |
| 44 | +You can find all available environment variables [here](../mergince/#how-to-deploy-mergin-maps-ce) together with a tutorial how to set them up. |
| 45 | +::: |
| 46 | + |
| 47 | +Further, you need to set a default role for people in your workspace. **Pick one** of these options |
| 48 | +(*learn more about our [permissions and roles system here](../../manage/permissions)*): |
| 49 | + |
| 50 | + - `GLOBAL_READ=0` everyone will have guest role (without access to any project unless explicitly granted) |
| 51 | + - `GLOBAL_READ=1` everyone will have reader role (they can read/download all projects in the workspace) |
| 52 | + - `GLOBAL_WRITE=1` everyone will have writer role (they can contribute to all projects in the workspace, e.g. upload files) |
| 53 | + - `GLOBAL_ADMIN=1` everyone will have admin role (they can create new projects and share projects with others) |
| 54 | + |
| 55 | +You can specify the maximum storage for your shiny new workspace 🌟 with the following variable: |
| 56 | + |
| 57 | + - `GLOBAL_STORAGE=10737418240` - workspace storage in bytes (10 GB in the example) |
| 58 | + |
| 59 | +:::tip |
| 60 | +New users can be created from <MainPlatformName /> administration panel, by navigating to `<your_url>/admin`. |
| 61 | +::: |
| 62 | + |
| 63 | + 1. Make sure projects volume mounts in `docker-compose` file still match (You can set up new volumes by following the [quick start guide](../mergince/#how-to-deploy-mergin-maps-ce)). Switch to new server version and PostgreSQL to at least version 12 (14 recommended) by running new docker containers: |
| 64 | +```bash |
| 65 | +$ docker-compose -f docker-compose.yml up |
| 66 | +``` |
| 67 | + |
| 68 | + 1. Restore backup from older PostgreSQL version, e.g.: |
| 69 | + |
| 70 | +```bash |
| 71 | +$ docker cp pg_backup.dump merginmaps-db:/tmp |
| 72 | +$ docker exec -it merginmaps-db bash |
| 73 | +root@merginmaps-db$ pg_restore -U postgres -Fc -d postgres < /tmp/pg_backup.dump |
| 74 | +``` |
| 75 | + |
| 76 | +*You might see some warnings about using public schema, you can safely ignore those.* |
| 77 | + |
| 78 | +:::warning |
| 79 | +If your PostgreSQL settings were custom, you might need to follow official instructions for upgrading the PostgreSQL cluster. |
| 80 | +::: |
| 81 | + |
| 82 | +**Database migration** |
| 83 | + |
| 84 | +In this step we will select a global workspace (e.g. my-company) where all your projects will be merged. Your projects are migrated as follows: former namespace is prepended to project name and whole project is moved to new global workspace, for example: |
| 85 | + |
| 86 | + john.doe/survey -> my-company/john.doe_survey |
| 87 | + my-org/projectA -> my-company/my-org_projectA |
| 88 | + |
| 89 | +Run DB migration scripts in `merginmaps-server` container: |
| 90 | + |
| 91 | +```bash |
| 92 | +$ docker exec -it merginmaps-server bash |
| 93 | + |
| 94 | +# stamp database to state of release 2021.6.1, |
| 95 | +# if there is existing alembic record you might need to patch it manually |
| 96 | +$ flask db stamp 2686074eff45 # ← state of 2021.6.1 |
| 97 | +$ flask db upgrade dbd428cda965 # sync with pre-2023 releases |
| 98 | +$ flask db upgrade 0ab6a1fbf974 |
| 99 | + |
| 100 | +$ echo $GLOBAL_WORKSPACE # make sure the GLOBAL_WORKSPACE variable is set and has the desired value |
| 101 | + |
| 102 | +$ flask db upgrade 35af0c8be41e |
| 103 | +$ flask db upgrade 1fcbea2a0f2c |
| 104 | +$ flask db upgrade 3daefa84ce67 |
| 105 | +$ flask db upgrade b6cb0a98ce20 |
| 106 | +``` |
| 107 | + |
| 108 | +If all goes well your database should end up in the following state |
| 109 | + |
| 110 | +```bash |
| 111 | +$ flask db current |
| 112 | +INFO [alembic.runtime.migration] Context impl PostgresqlImpl. |
| 113 | +INFO [alembic.runtime.migration] Will assume transactional DDL. |
| 114 | +b6cb0a98ce20 (head) |
| 115 | +35af0c8be41e (head) |
| 116 | +``` |
| 117 | +Your should be successfully migrated. Please note that files on your disk were not touched, only project names (namespaces) were changed. |
| 118 | + |
| 119 | +You can now download and continue working with your projects. |
0 commit comments