fix: [outline] align database ownership before migrations

The ``pre_deploy`` hook reassigns every object of the outline database
(tables, sequences, views, materialized views, standalone types,
functions, procedures) to the application role before the container
runs its migrations.

Historical provisioning or restores running as the ``postgres``
superuser leave objects owned by ``postgres``, so any later ``ALTER``
on them fails with "must be owner of ..." and puts outline in a
crash-loop at migration time.  Seen on elabore.coop when upgrading
1.6.1 -> 1.10.0: migration
``20260714000000-add-mcp-to-search-queries-source.js`` failed on
``enum_search_queries_source``.

Extensions are excluded from the realignment (they are managed by the
``postgres`` charm).  The hook is idempotent, silent when there is no
drift, and blocks the deployment (``exit 1``) if any drift remains, so
the problem surfaces at deploy time instead of as a cryptic
crash-loop.
This commit is contained in:
Stéphan Sainléger
2026-09-16 23:41:42 +02:00
parent 31bcaab87f
commit 9947900389
4 changed files with 250 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
outline:
options:
sender-email: outline@example.com
oidc-client-id: test-client
oidc-client-secret: test-secret
oidc-auth-uri: https://example.com/auth
oidc-token-uri: https://example.com/token
oidc-user-info-uri: https://example.com/userinfo
oidc-logout-uri: https://example.com/logout
smtp-stub:
options:
host: smtp.example.com