Migrations
Migrations module is introduced in [[changelog#1 1 1|v1.1.1]] of API and provides one-shot migrations which cannot be performed from the NixOS configuration file changes. These migrations are checked and ran before every start of the API.
You can disable certain migrations if needed by creating an array at api.skippedMigrations
in userdata.json
and populating it with IDs of the migrations to skip. Adding DISABLE_ALL
to that array disables the migrations module entirely.
For example:
...
"api": {
"token": "secret_token",
"enableSwagger": false,
"skippedMigrations": [ "fix_nixos_config_branch", "create_tokens_json" ]
},
...
Fix NixOS configuration branch
Migration ID: fix_nixos_config_branch
Introduced in: [[changelog#1 1 1|v1.1.1]]
Description
Mobile SelfPrivacy app introduced a bug in version 0.4.0. New servers were initialized with a rolling-testing nixos config branch. This was fixed in app version 0.4.2, but existing servers were not updated. This migration fixes this by changing the nixos config branch to master.
Run conditions
Git repository at /etc/nixos
is using rolling-testing
branch.
Migration process
- Moving context to
/etc/nixos
. - Running
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
to fix the consequences of--single-branch
flag. git fetch --all
to fetch all existing branches.git pull
to pull them.git checkout master
moves to master.- Leaving the context.
Create tokens JSON file
Migration ID: create_tokens_json
Introduced in: [[changelog#1 2 0|v1.2.0]]
Description
Selfprivacy API used a single token in userdata.json
for authentication.
This migration creates a new tokens.json
file with the old token in it.
Run conditions
/etc/nixos/userdata/tokens.json
does not exist.
Migration process
- Current token is retrieved from
userdata.json
. tokens.json
is created with 0600 permission.- File is populated with the following data:
{
"tokens": [
{
"token": "token_string",
"name": "primary_token",
"date": "current date from str(datetime.now())",
}
]
}