Commit 9f08cf2
fix: move snapshot deduplication outside IF block to handle existing duplicates
The deduplication logic was inside IF NOT EXISTS (snapshot_date), so it only
ran on fresh databases. Existing databases with duplicate data would fail to
create the unique index during AutoMigrate.
Move the DELETE statement outside the IF block so it runs on EVERY deployment,
ensuring duplicate data is cleaned up before AutoMigrate attempts to create
the unique index idx_campaign_snapshot_date.
Fixes deployment failure: ERROR: could not create unique index
"idx_campaign_snapshot_date" (SQLSTATE 23505)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 71dd293 commit 9f08cf2
1 file changed
Lines changed: 7 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | 173 | | |
180 | 174 | | |
181 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
| |||
0 commit comments