Skip to content

[#240] Fix contract address backfill for pre-redeploy data#241

Merged
realproject7 merged 2 commits intomainfrom
task/240-fix-contract-address-backfill
Mar 17, 2026
Merged

[#240] Fix contract address backfill for pre-redeploy data#241
realproject7 merged 2 commits intomainfrom
task/240-fix-contract-address-backfill

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Migration 00009 incorrectly defaulted existing rows to the new contract address (0x6b8d...)
  • All pre-redeploy data was actually created on the old contract (0x05c4...)
  • New migration 00012 re-tags all 6 tables back to the correct old contract address
  • Operator action needed: Run the same SQL manually against Supabase to fix production data immediately

Test plan

  • Migration applies cleanly
  • Old data tagged with old contract address (0x05c4...)
  • Home page shows empty (no storylines on new contract yet)
  • Old data still queryable with old contract address filter

Fixes #240

🤖 Generated with Claude Code

Re-tag all existing rows from the new contract address (0x6b8d...)
back to the old contract (0x05c4...) where they were actually created.
Migration 00009 incorrectly defaulted to the new address.

Fixes #240

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The migration matches the issue write-up, but as written it is not environment-safe. It blindly rewrites every row tagged with the new contract address, so any environment that has already indexed legitimate new-contract data will have that data silently corrupted back to the old address.

Findings

  • [high] 00012_fix_contract_address_backfill.sql updates all rows with contract_address = 0x6b8d... across all six tables, with no predicate that distinguishes wrongly backfilled pre-redeploy rows from legitimate new-contract rows.
    • File: supabase/migrations/00012_fix_contract_address_backfill.sql:5
    • Suggestion: make the backfill targetable and provably safe, for example by constraining on a pre-redeploy cutoff (indexed_at/block_timestamp) or on a known bounded data set, rather than rewriting every row with the new address. At minimum, the migration should fail closed unless the operator explicitly confirms the environment contains no real new-contract data.

Decision

Requesting changes because this migration can corrupt legitimate data in any environment where new-contract rows already exist, and the safety assumption is not encoded anywhere in the SQL.

Only re-tag rows created/indexed before 2026-03-17T09:00:00Z to avoid
overwriting any legitimate new-contract data indexed after migration
00009 was deployed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

Re-review complete. The backfill is now scoped to a concrete pre-deploy cutoff (2026-03-17T09:00:00Z) using the relevant timestamp columns per table, which prevents the migration from blindly retagging legitimate new-contract rows created after that point.

Findings

  • None. The migration now encodes the safety assumption that was previously only implicit.

Decision

Approving because the follow-up makes the contract-address backfill fail closed to pre-cutoff data instead of rewriting every 0x6b8d... row indiscriminately. CI was still pending at the time of review.

@realproject7 realproject7 merged commit 6625575 into main Mar 17, 2026
1 check passed
realproject7 added a commit that referenced this pull request Mar 22, 2026
…addresses

P5-8c: Update testnet constants after P5-8a/b deployments:
- PLOT_TOKEN testnet: PL_TEST (0x6Ef4...13Fa) replaces WETH stand-in
- ZAP_PLOTLINK testnet: 0x38b0...a0D7
- RESERVE_LABEL: testnet "PL_TEST", mainnet "PLOT"
- Added UNISWAP_V4_POOL_MANAGER constant

Fixes #241 (partial — P5-8 only)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realproject7 added a commit that referenced this pull request Mar 22, 2026
- Updated ZAP_PLOTLINK testnet to redeployed address (0xC7C47D8...)
- Reverted RESERVE_LABEL mainnet value to "PL_TEST" (out-of-scope change)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
realproject7 added a commit that referenced this pull request Mar 22, 2026
[#241] P5-8c: Update constants with PL_TEST, ZapPlotLink addresses
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.

[Bug] Migration 00009 tagged old data with wrong contract address

2 participants