mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
- Replace 13 raw `container exec mysql/psql` invocations across
web-app-pixelfed, web-app-fider, and web-app-mattermost with the
canonical `database_query` module + `query_file:` + `named_args:`
pattern. The module already speaks both shared (central `svc-db-*`)
and non-shared (per-role `<entity>-database`) modes via the
`database` lookup, so the same task shape works regardless of DB
topology — the per-role hardcoded container-exec argv was the only
blocker.
- Extract every inline SQL body into per-role `files/sql/` trees.
Pixelfed splits further into `files/sql/oidc-mapping/` because the
OIDC-mapping cluster is a distinct concern from the bootstrap /
administrator queries. Each SQL file is single-purpose and named by
verb-noun (count-users, select-admin-id, upsert, etc.) to match the
precedent set by web-app-odoo.
- Fider's existing `files/{create_admin_user,configure_oidc_provider}.sql`
move to `files/sql/` and switch from psql-specific `:'var'`
variable substitution (which forced `stdin:` piping with `-v`
flags) to engine-neutral `%(name)s` placeholders the module
escapes per backend.
- Pixelfed loses `PIXELFED_MARIADB_ARGS` + 3 derived DB vars
(`*_CONTAINER`, `*_USERNAME`, `*_PASSWORD`) from `vars/main.yml` —
they were the manual argv bundle for the old container-exec
pattern and become orphan once `lookup('database', application_id)`
takes over.
- Every refactored task carries `mask_values:
MASK_CREDENTIALS_IN_LOGS` (module-level credential redaction);
tasks that previously used `no_log: MASK_CREDENTIALS_IN_LOGS`
keep both directives so the task-level masking stays alongside
the module-level one.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23 lines
787 B
SQL
23 lines
787 B
SQL
-- Idempotent INSERT for the Fider admin user (bypasses email verification).
|
|
-- Inserts a row into `users` if not present, then marks any pending
|
|
-- email_verifications row for that email as verified.
|
|
|
|
INSERT INTO users (name, email, created_at, tenant_id, role, status, avatar_type, avatar_bkey)
|
|
SELECT
|
|
%(full_name)s,
|
|
%(email)s,
|
|
NOW(),
|
|
(SELECT id FROM tenants LIMIT 1),
|
|
3, 1, 2, ''
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM users
|
|
WHERE email = %(email)s
|
|
AND tenant_id = (SELECT id FROM tenants LIMIT 1)
|
|
);
|
|
UPDATE email_verifications
|
|
SET verified_at = NOW(),
|
|
user_id = (SELECT id FROM users
|
|
WHERE email = %(email)s
|
|
AND tenant_id = (SELECT id FROM tenants LIMIT 1))
|
|
WHERE email = %(email)s AND verified_at IS NULL;
|