• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kobotoolbox / kpi / 24841258195 / 3
82%
master: 76%

Build:
Build:
LAST BUILD BRANCH: main
DEFAULT BRANCH: master
Ran 23 Apr 2026 02:46PM UTC
Files 910
Run time 42s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

23 Apr 2026 02:35PM UTC coverage: 53.939% (-6.3%) from 60.272%
24841258195.3

push

github

web-flow
fix(user_reports): drop and recreate materialized view around djstripe migrations DEV-2015 (#6960)

### 👷 Description for instance maintainers
This PR resolves a migration failure caused by the
`user_reports_userreportsmv` materialized view, which depends on columns
altered by djstripe 2.9 migrations (notably `djstripe_price.type` and
`djstripe_product.type` in `djstripe.0013_2_9`).

Without this fix, `djstripe.0013_2_9` fails with:
`cannot alter type of a column used by a view or rule`


### Notes 

**Race-condition safeguards during DROP**
The Celery task `refresh_user_report_snapshots` periodically runs
`REFRESH MATERIALIZED VIEW CONCURRENTLY`, which would block the `DROP`.
The migration now:

1. Acquires the Redis lock `billing_and_usage_snapshot:run_lock`
(blocking, 5s timeout) to prevent new task runs.
2. If the lock is already held, calls `pg_terminate_backend()` on any
backend refreshing the MV or holding a lock on it. The terminated Celery
task then releases the Redis lock through its own `finally` block. The
MV is about to be dropped, so losing an in-flight refresh is harmless.
3. Sets a PostgreSQL `lock_timeout = '30s'` as a belt-and-braces safety
net before issuing the `DROP`.

### 👀 Preview steps

1. â„šī¸ Have Stripe enabled and an account with a paid subscription plan.
2. Verify `/api/v2/user_reports/` lists users with their Stripe plans.
3. Roll djstripe back: `./manage.py migrate djstripe 0012_2_8`.
4. 🔴 [on `release/2.026.12`] Re-running migrations fails on
`djstripe.0013_2_9` with the materialized view dependency error.
5. Check out this PR branch and run `./manage.py migrate` 🎉.
6. đŸŸĸ The `user_reports` migration drops the MV before djstripe runs, and
djstripe migrations complete successfully.
7. The LRM runner (Celery Beat task `execute_long_running_migrations`)
runs every 15 minutes on the quarter hour and will recreate the MV in
the background. To force it immediately, call
`kobo.apps.long_running_migrations.tasks.execute_long_runni... (continued)

3650 of 11834 branches covered (30.84%)

19391 of 35950 relevant lines covered (53.94%)

0.54 hits per line

Source Files on job 24841258195.3
  • Tree
  • List 910
  • Changed 155
  • Source Changed 0
  • Coverage Changed 155
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 24841258195
  • d87feb8f on github
  • Prev Job for on release/2.026.12 (#24837117774.6)
  • Next Job for on release/2.026.12 (#24983934715.1)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc