docs(ops): cleanup must run as RLS-bypassing role, stop on error
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,11 +11,11 @@ Owner go-ahead required before step 4. Never run during business hours without t
|
||||
```
|
||||
Create `/srv/apps/ims/backups` first if missing. Both files must be non-empty.
|
||||
2. **Upload** `db/ops/cleanup-test-data.sql` to `/srv/apps/ims/backups/` (not into `app/`).
|
||||
3. **Dry run** as the DB owner:
|
||||
3. **Dry run.** Use a DB role that owns the tables and bypasses RLS (superuser, or the owner role with BYPASSRLS). The tables have FORCE RLS and no DELETE policies, so as `app_user` or a plain owner the counts can read 0 and deletes silently remove nothing. Check first: `psql -p 5433 -d ims -Atc "select rolsuper or rolbypassrls from pg_roles where rolname = current_user"` must print `t`. Then:
|
||||
```bash
|
||||
psql -p 5433 -d ims -v mode=dryrun -f /srv/apps/ims/backups/cleanup-test-data.sql
|
||||
```
|
||||
Send the admins list and the row counts to the owner. Stop here until they confirm.
|
||||
Send the admins list and the row counts to the owner. If incidents or users show 0 when the app shows rows, you are on the wrong role: stop. Mention that audit_log rows written by non-admin users about other tables (zones, trucks, settings) are also removed. Stop here until they confirm.
|
||||
4. **Run** after explicit confirmation:
|
||||
```bash
|
||||
psql -p 5433 -d ims -v ON_ERROR_STOP=1 -v mode=run -f /srv/apps/ims/backups/cleanup-test-data.sql
|
||||
|
||||
Reference in New Issue
Block a user