Split the legacy campaign backfill into per-period campaigns - #359
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: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).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.