Skip to content

fix(backend): make analytics migrations compatible with supported PostgreSQL (#1702) - #1719

Merged
blurbeast merged 2 commits into
LabsCrypt:mainfrom
intelliDean:fix/1702-analytics-timescaledb-migration
Oct 22, 2026
Merged

blurbeast merged 2 commits into
LabsCrypt:mainfrom
intelliDean:fix/1702-analytics-timescaledb-migration

Conversation

@intelliDean

Copy link
Copy Markdown
Contributor

Closes #1702

Summary

  • Wrapped TimescaleDB extension, hypertable, continuous aggregates, and compression policies in dynamic EXECUTE within a conditional DO $ block checking pg_available_extensions.
  • Fixed prerequisite migrations for clean PostgreSQL replay:
    • Added inline unique constraints in 20260221132622_init for foreign key ordering.
    • Added IF NOT EXISTS for endTime column in 20260729170000_timestamp_bigint.
    • Added DROP TABLE IF EXISTS CASCADE in 20260926000000_add_indexer_dead_letter_event to avoid duplicate table collisions.
  • Updated .github/workflows/ci.yml to run prisma migrate deploy from an empty database.

Testing

  • Verified npx prisma migrate deploy cleanly applies all 18 migrations from an empty database.
  • Verified analytics TVL and historical metrics under both TimescaleDB and live aggregation fallback.
  • All 64 backend unit test suites passed.

…tgreSQL (LabsCrypt#1702)

- Guard TimescaleDB extension, hypertables, continuous aggregates, and compression policies in 20261001000000_add_timescaledb_analytics with dynamic execution when timescaledb extension is present, safely falling back to live aggregation when absent
- Fix foreign key ordering on PostgreSQL in 20260221132622_init by adding inline unique constraints on table creation
- Support clean migration replay in 20260729170000_timestamp_bigint with IF NOT EXISTS for endTime column
- Drop existing table cascade in 20260926000000_add_indexer_dead_letter_event to resolve collision with duplicate earlier migration
- Update CI workflow to use prisma migrate deploy from an empty database instead of prisma db push
@blurbeast
blurbeast merged commit 9dd1ce0 into LabsCrypt:main Oct 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] Make analytics migrations compatible with supported PostgreSQL

2 participants