coreapp.toml's [postgres] extensions = ["vector"]: the installer checks the Core's PostgreSQL has each one (refusing before anything changes if not) and makes them in the app's database as the superuser, with CASCADE, on install and every update. Ones taken off the list are kept, since the data may use them. Also fixes the check refusing needs with both postgres and mysql, which never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
1.0 KiB
Plaintext
19 lines
1.0 KiB
Plaintext
# Its own database and user on the Core's PostgreSQL,
|
|
# with the password from .env. Safe to run again: an existing user gets the
|
|
# password, an existing database is kept.
|
|
DB_PASSWORD="$(sed -n 's/^DB_PASSWORD=//p' /federated/apps/{{NAME}}/.env)"
|
|
if docker exec postgresql psql -U postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname = '{{DBNAME}}'" | grep -q 1; then
|
|
docker exec postgresql psql -U postgres -qc "ALTER USER {{DBNAME}} WITH PASSWORD '$DB_PASSWORD'"
|
|
else
|
|
docker exec postgresql psql -U postgres -qc "CREATE USER {{DBNAME}} WITH PASSWORD '$DB_PASSWORD'"
|
|
fi
|
|
if ! docker exec postgresql psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname = '{{DBNAME}}'" | grep -q 1; then
|
|
docker exec postgresql psql -U postgres -qc "CREATE DATABASE {{DBNAME}} OWNER {{DBNAME}}"
|
|
fi
|
|
unset DB_PASSWORD
|
|
# The extensions coreapp.toml asks for (also kept current by update)
|
|
for extension in {{EXTENSIONS}}; do
|
|
docker exec postgresql psql -U postgres -d {{DBNAME}} -v ON_ERROR_STOP=1 -qc "CREATE EXTENSION IF NOT EXISTS \"$extension\" CASCADE"
|
|
done
|
|
unset extension
|