Repository navigation
chore(db): mirror the four older drift migrations from dos-me - #1612
Conversation
DOS/DOS.Me is the only deployable ledger. Four rate migrations differed between it and supabase/migrations: - 20261013192302_jreviews_rating_and_review_flags.sql and 20261014011054_review_votes.sql: the DOS.Me version is the one on production (no explanatory comments; review_flags policies created only when missing). Replace the reference copies with it. - 20261025090000_rate_product_images_bucket.sql: only in DOS.Me. It needs the Supabase storage schema, so the replay skips it, as DOS.Me's own replay does (NOT_REPLAYED in scripts/lib/rate-db.mjs). - 20261106150000_rate_listing_price_context_peer_max_history_first.sql: only in DOS.Me (Rate-Services price context). Mirrored, and database.types.ts regenerated: history_first_at and peer_reference_max. Nothing is applied by this change. Refs #1606 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Refs #1606
DOS/DOS.Me is the only deployable ledger for the
rateschema.scripts/check-migration-drift.mjslisted four older differences, none from M2. This PR mirrors them from DOS.Medev, byte for byte, and applies nothing.What
20261013192302_jreviews_rating_and_review_flags.sql: DOS.Me has no explanatory comments, and creates the tworeview_flagspolicies only when missing, where the copy here dropped one.20261014011054_review_votes.sql: DOS.Me has no explanatory comments.20261025090000_rate_product_images_bucket.sql(the product image mirror bucket, fix(web): TGDD listing thumbnails are blocked by the CDN's hotlink protection #887). It needs the Supabasestorageschema, which the throwaway database does not have.scripts/lib/rate-db.mjsgets aNOT_REPLAYEDlist, as DOS.Me's own replay has, naming the test that covers it instead (scripts/ci/rate-product-images-bucket.integration.test.mjsin DOS.Me). The replay, the type generator and the E2E stack skip it.20261106150000_rate_listing_price_context_peer_max_history_first.sql(the Rate-Services price context).packages/shared-data/src/database.types.ts, regenerated withpnpm gen:db-types. It addshistory_first_atandpeer_reference_max, the two outputs of the price context function.Checks (local)
scripts/test-migration-replay.mjs: 36 migrations applied twice on PostgreSQL 17, passed.dev, now lists only the four M2 migrations, which chore(db): mirror the m2 extension observation migrations from dos-me #1611 mirrors.Notes
database.types.tsin different places. Whichever merges second needs a regeneration (pnpm gen:db-types), which is deterministic.Codex not run.
🤖 Generated with Claude Code
📌 TL;DR
This PR enhances the price anomaly detection system by adding
peer_reference_maxandhistory_first_atmetrics to thelisting_price_contextfunction, allowing auditors to better distinguish legitimate MSRP strikes from inflated fake sales. It also introduces a new Supabase storage bucket for product image mirroring and refactors existing migrations to be idempotent for safe replay.🎯 Type of Change
🔍 Changes Walkthrough
packages/shared-data/src/database.types.tshistory_first_atandpeer_reference_maxfields in the database schema.scripts/lib/rate-db.mjsNOT_REPLAYEDmap to exclude specific migrations (like the storage bucket one) from the throwaway test database replay, as they require specific Supabase storage schemas.supabase/migrations/20261013192302_jreviews_rating_and_review_flags.sqlIF NOT EXISTSchecks) and removed verbose comments to ensure safe re-execution.supabase/migrations/20261014011054_review_votes.sqlsupabase/migrations/20261025090000_rate_product_images_bucket.sqlrate-product-imagesstorage bucket with strict RLS policies to prevent non-service roles from accessing or modifying the bucket, supporting image mirroring for hotlink protection.supabase/migrations/20261106150000_rate_listing_price_context_peer_max_history_first.sqlrate.listing_price_contextfunction to includepeer_reference_max(highest peer price) andhistory_first_at(oldest price point timestamp), enabling more accurate fake sale detection.📊 Architectural Flow
flowchart TD subgraph "Rate-Services / Auditors" A[Price Anomaly Auditor] -->|Queries| B[rate.listing_price_context] end subgraph "Supabase Database" B -->|Reads| C[rate.products] B -->|Reads| D[rate.merchants] B -->|Reads| E[rate.price_history] C -->|Joins| F[Cluster Peers] E -->|Aggregates| G[History Metrics] F -->|Calculates| H[peer_reference_max] G -->|Calculates| I[history_first_at] H --> B I --> B end subgraph "Storage" J[rate-product-images Bucket] -->|Serves| K[rate.vn Frontend] L[Service Role] -->|Writes| J end