Skip to content

Commit

Permalink
entrypoint.sh: Migrate data stores before any other migrations
Browse files Browse the repository at this point in the history
The migration code checks that the migration hasn't already happened (e.g. by
testing whether prosody.sqlite exists). However we do various other operations
before this point (via prosodyctl) which may initialize the new data store of
the desired type.

If this happens, the migration code will assume that a migration already
happened and skip the migration.

This changes the order to ensure data store migrations always happen first,
and adds a comment to inform future devs about this potential issue.
  • Loading branch information
mwild1 committed Aug 12, 2024
1 parent 6239858 commit f89e014
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,9 @@ if test -f /snikket/prosody/turn-auth-secret; then
rm /snikket/prosody/turn-auth-secret;
fi

if test -d /snikket/prosody/http_upload; then
prosodyctl mod_migrate_http_upload "share.$SNIKKET_DOMAIN" "$SNIKKET_DOMAIN"
fi

# COMPAT: migrate from 0.12 series role storage
if ! test -d /snikket/prosody/*/account_roles; then
prosodyctl mod_authz_internal migrate "$SNIKKET_DOMAIN"
fi

# Migrate from prosody:normal to prosody:registered
prosodyctl mod_migrate_snikket_roles migrate "$SNIKKET_DOMAIN"
# Migrate between storage backends if needed
# Note: this happens before we do any other operations that touch Prosody's
# data store, to ensure consistency.

if test "${SNIKKET_TWEAK_STORAGE:-files}" = "sqlite" && ! test -f /snikket/prosody/prosody.sqlite; then
sed -i "s/SNIKKET_DOMAIN/$SNIKKET_DOMAIN/" /etc/prosody/migrator.cfg.lua
Expand All @@ -86,4 +78,16 @@ elif test "${SNIKKET_TWEAK_STORAGE:-files}" = "files" && test -f /snikket/prosod
fi
fi

if test -d /snikket/prosody/http_upload; then
prosodyctl mod_migrate_http_upload "share.$SNIKKET_DOMAIN" "$SNIKKET_DOMAIN"
fi

# COMPAT: migrate from 0.12 series role storage
if ! test -d /snikket/prosody/*/account_roles; then
prosodyctl mod_authz_internal migrate "$SNIKKET_DOMAIN"
fi

# Migrate from prosody:normal to prosody:registered
prosodyctl mod_migrate_snikket_roles migrate "$SNIKKET_DOMAIN"

exec s6-svscan /etc/sv

0 comments on commit f89e014

Please sign in to comment.