Skip to content

Split the legacy campaign backfill into per-period campaigns - #359

Merged
mindsers merged 1 commit into
mainfrom
feat/split-campaign-backfill
Aug 23, 2026
Merged

Split the legacy campaign backfill into per-period campaigns#359
mindsers merged 1 commit into
mainfrom
feat/split-campaign-backfill

Conversation

@mindsers

Copy link
Copy Markdown
Contributor

Follow-up to #335. The campaigns migration backfills legacy type = 'campaign' attributions into one synthetic ended « Campagne » per congregation — losing the distinction between historical drives. This data-only migration splits each synthetic into one campaign per date cluster:

  • A gap of more than 30 days between an attribution's start and the latest end seen so far opens a new cluster.
  • Each cluster becomes an already-ended campaign named by its period (« Campagne 03/2024 »), attributions are repointed, and the emptied synthetic is dropped.
  • Synthetics are recognized by the backfill's exact stamps (name = 'Campagne' + activatedAt = startDate + endedAt = endDate), so campaigns that went through the real lifecycle — even ones a user named « Campagne » — are untouched, as are single-cluster synthetics (splitting those would just be a rename).
  • Implemented as a single data-modifying CTE chain: temp tables don't survive Prisma's per-statement execution.

No schema change — nothing to sync to the platform repo.

Verified on the dev database with seeded states: a 5-attribution synthetic spanning 2024–2026 split into « Campagne 03/2024 » (2), « Campagne 11/2024 » (1), « Campagne 03/2026 » (2); a lifecycle-stamped decoy named « Campagne » and a single-cluster synthetic were left untouched. Unit (3134) and integration (322) suites green.

Ordering note: this lands after 20260823000000_add_publishing_campaigns, so on a production deploy both run in sequence — the collapse never becomes user-visible.

… campaigns

The campaigns migration collapsed all legacy type='campaign' attributions
into one synthetic ended 'Campagne' per congregation. This follow-up data
migration splits each synthetic into one campaign per date cluster (a gap of
more than 30 days between an attribution's start and the latest end seen so
far opens a new cluster), named by its period ('Campagne 03/2024'),
repoints the attributions and drops the emptied synthetic. Synthetics are
recognized by the backfill's exact stamps (name + activatedAt = startDate +
endedAt = endDate), so campaigns that went through the real lifecycle —
even ones named 'Campagne' — and single-cluster synthetics are untouched.
Single data-modifying CTE chain (temp tables don't survive Prisma's
statement execution); verified against seeded multi-cluster, decoy and
single-cluster states on the dev database.
@mindsers
mindsers merged commit d7af804 into main Aug 23, 2026
6 checks passed
@mindsers
mindsers deleted the feat/split-campaign-backfill branch August 23, 2026 20:31
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.

1 participant