chore(db): reset drizzle migrations with baseline#142
Conversation
✅ Deploy Preview for develop-devlovers ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThis PR introduces database schema files including PostgreSQL migrations, metadata snapshots, and journal entries. It defines a comprehensive schema with UUID-based primary keys covering quiz management, user accounts, product catalog, inventory, orders, payments, and authentication tokens with numerous constraints and indexes for data integrity. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (44)
frontend/db/legacy-migrations/drizzle_legacy/0000_rich_magus.sqlfrontend/db/legacy-migrations/drizzle_legacy/0001_black_random.sqlfrontend/db/legacy-migrations/drizzle_legacy/0002_yielding_purple_man.sqlfrontend/db/legacy-migrations/drizzle_legacy/0003_handy_cammi.sqlfrontend/db/legacy-migrations/drizzle_legacy/0004_tough_ultron.sqlfrontend/db/legacy-migrations/drizzle_legacy/0005_furry_warstar.sqlfrontend/db/legacy-migrations/drizzle_legacy/0006_minor_units_money.sqlfrontend/db/legacy-migrations/drizzle_legacy/0007_add-payment-intent-id-to-orders.sqlfrontend/db/legacy-migrations/drizzle_legacy/0008_dizzy_james_howlett.sqlfrontend/db/legacy-migrations/drizzle_legacy/0009_p0_inventory_workflow_baseline.sqlfrontend/db/legacy-migrations/drizzle_legacy/0009_unknown_nico_minoru.sqlfrontend/db/legacy-migrations/drizzle_legacy/0010_parallel_princess_powerful.sqlfrontend/db/legacy-migrations/drizzle_legacy/0011_add_orders_sweep_claim_index.sqlfrontend/db/legacy-migrations/drizzle_legacy/0012_inventory_moves_product_fk_restrict.sqlfrontend/db/legacy-migrations/drizzle_legacy/0013_add_internal_job_state.sqlfrontend/db/legacy-migrations/drizzle_legacy/0013_brown_gamora.sqlfrontend/db/legacy-migrations/drizzle_legacy/0013_low_roughhouse.sqlfrontend/db/legacy-migrations/drizzle_legacy/0014_add-stripe-events-processed-at.sqlfrontend/db/legacy-migrations/drizzle_legacy/0014_dapper_kang.sqlfrontend/db/legacy-migrations/drizzle_legacy/0014_steep_kabuki.sqlfrontend/db/legacy-migrations/drizzle_legacy/0015_dear_legion.sqlfrontend/db/legacy-migrations/drizzle_legacy/0015_glamorous_eternity.sqlfrontend/db/legacy-migrations/drizzle_legacy/0015_warm_dexter_bennett.sqlfrontend/db/legacy-migrations/drizzle_legacy/meta/0000_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0001_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0002_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0003_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0004_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0005_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0006_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0007_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0008_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0009_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0010_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0012_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0013_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0014_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/0015_snapshot.jsonfrontend/db/legacy-migrations/drizzle_legacy/meta/_journal.jsonfrontend/db/legacy-migrations/drizzle_legacy/relations.tsfrontend/db/legacy-migrations/drizzle_legacy/schema.tsfrontend/drizzle/0000_dry_young_avengers.sqlfrontend/drizzle/meta/0000_snapshot.jsonfrontend/drizzle/meta/_journal.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-30T16:01:02.523Z
Learnt from: kryvosheyin
Repo: DevLoversTeam/devlovers.net PR: 88
File: frontend/drizzle/schema.ts:153-153
Timestamp: 2025-12-30T16:01:02.523Z
Learning: The file frontend/drizzle/schema.ts is a legacy file not used by Drizzle or the runtime. The canonical schemas live in frontend/db/schema/* as configured in drizzle-config.ts, and that's what migrations and runtime use.
Applied to files:
frontend/db/legacy-migrations/drizzle_legacy/meta/0000_snapshot.jsonfrontend/drizzle/0000_dry_young_avengers.sql
🪛 Biome (2.1.2)
frontend/db/legacy-migrations/drizzle_legacy/meta/_journal.json
[error] 98-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: expected , but instead found HEAD
Remove HEAD
(parse)
[error] 100-100: expected , but instead found "when"
Remove "when"
(parse)
[error] 100-100: expected , but instead found :
Remove :
(parse)
[error] 100-100: expected , but instead found 1768162667947
Remove 1768162667947
(parse)
[error] 101-101: expected , but instead found :
Remove :
(parse)
[error] 101-101: expected , but instead found "0013_brown_gamora"
Remove "0013_brown_gamora"
(parse)
[error] 101-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 103-103: expected , but instead found "when"
Remove "when"
(parse)
[error] 103-103: expected , but instead found :
Remove :
(parse)
[error] 103-103: expected , but instead found 1767697281389
Remove 1767697281389
(parse)
[error] 104-104: expected , but instead found :
Remove :
(parse)
[error] 104-104: expected , but instead found "0013_low_roughhouse"
Remove "0013_low_roughhouse"
(parse)
[error] 105-105: expected , but instead found :
Remove :
(parse)
[error] 105-105: expected , but instead found true
Remove true
(parse)
[error] 106-106: expected , but instead found }
Remove }
(parse)
[error] 106-106: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 107-113: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 113-113: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 114-118: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 118-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: String values must be double quoted.
(parse)
[error] 119-119: unexpected character (
(parse)
[error] 119-119: String values must be double quoted.
(parse)
[error] 119-119: unexpected character (
(parse)
[error] 119-119: String values must be double quoted.
(parse)
[error] 119-119: unexpected character )
(parse)
[error] 119-119: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 119-119: unexpected character )
(parse)
[error] 120-120: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 120-120: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 120-120: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 121-121: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 122-128: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 129-130: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
🔇 Additional comments (7)
frontend/db/legacy-migrations/drizzle_legacy/meta/0000_snapshot.json (1)
1-947: LGTM - Legacy migration snapshot properly archived.This snapshot correctly preserves the historical schema state for reference. The structure is valid and maintains the pre-baseline migration history as documented in the PR objectives.
frontend/drizzle/meta/_journal.json (1)
1-13: LGTM - Clean baseline migration journal.The journal correctly reflects a fresh linear migration history with a single baseline entry, which aligns with the PR's objective to restore a reliable migration state.
frontend/drizzle/0000_dry_young_avengers.sql (4)
1-6: Well-structured ENUM types for domain modeling.The enum definitions provide clear domain boundaries for currency, inventory operations, order lifecycle, and payment states.
171-177: Excellent use of CHECK constraints for data integrity.The mirror consistency constraints (
order_items_line_total_consistent,order_items_unit_price_mirror_consistent, etc.) ensure the integer-cents and decimal columns stay synchronized at the database level, preventing data corruption from application bugs.
275-287: Verify intentional omission of foreign key on token tables.Both
email_verification_tokensandpassword_reset_tokensreferenceuser_idbut lack a foreign key constraint tousers.id. This is often intentional for auth tokens (allows independent cleanup, doesn't block user deletion), but worth confirming given the PR mentions these tables were recreated.
289-334: LGTM - Foreign keys and indexes well-defined.The foreign key behaviors (cascade, restrict, set null) are appropriately chosen for each relationship, and indexes support expected query patterns for lookups and filtering.
frontend/drizzle/meta/0000_snapshot.json (1)
1-2441: LGTM - Baseline snapshot consistent with SQL migration.The snapshot accurately reflects the schema defined in
0000_dry_young_avengers.sql, including all tables, enums, constraints, indexes, and foreign key relationships.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
| { | ||
| "idx": 13, | ||
| "version": "7", | ||
| <<<<<<< HEAD | ||
| "when": 1768162667947, | ||
| "tag": "0013_brown_gamora", | ||
| ======= | ||
| "when": 1767697281389, | ||
| "tag": "0013_low_roughhouse", | ||
| "breakpoints": true | ||
| }, | ||
| { | ||
| "idx": 14, | ||
| "version": "7", | ||
| "when": 1768045270184, | ||
| "tag": "0014_dapper_kang", | ||
| "breakpoints": true | ||
| }, | ||
| { | ||
| "idx": 15, | ||
| "version": "7", | ||
| "when": 1768166276337, | ||
| "tag": "0015_glamorous_eternity", | ||
| >>>>>>> b30415e (feat(auth): add email verification, password reset, and improved auth UX) | ||
| "breakpoints": true | ||
| }, | ||
| { | ||
| "idx": 14, | ||
| "version": "7", | ||
| "when": 1768304911639, | ||
| "tag": "0014_steep_kabuki", | ||
| "breakpoints": true | ||
| } | ||
| ] |
There was a problem hiding this comment.
Unresolved merge conflict renders file invalid.
This file contains unresolved Git merge conflict markers (<<<<<<< HEAD, =======, >>>>>>> b30415e), making it invalid JSON. This will cause Drizzle to fail when parsing migration metadata.
The conflict shows two divergent histories:
- HEAD: idx 13 →
0013_brown_gamora, then0014_steep_kabuki - Other branch: idx 13-15 →
0013_low_roughhouse,0014_dapper_kang,0015_glamorous_eternity
You need to resolve this conflict by choosing the correct migration history or, given this PR's baseline reset objective, potentially removing the conflicting entries entirely since this is archived legacy metadata.
🔧 Suggested resolution (if keeping as archive)
If this file should preserve pre-baseline history, resolve by keeping one consistent sequence:
{
"idx": 13,
"version": "7",
-<<<<<<< HEAD
- "when": 1768162667947,
- "tag": "0013_brown_gamora",
-=======
"when": 1767697281389,
"tag": "0013_low_roughhouse",
"breakpoints": true
},
{
"idx": 14,
"version": "7",
"when": 1768045270184,
"tag": "0014_dapper_kang",
"breakpoints": true
},
{
"idx": 15,
"version": "7",
"when": 1768166276337,
"tag": "0015_glamorous_eternity",
->>>>>>> b30415e (feat(auth): add email verification, password reset, and improved auth UX)
- "breakpoints": true
- },
- {
- "idx": 14,
- "version": "7",
- "when": 1768304911639,
- "tag": "0014_steep_kabuki",
"breakpoints": true
}
]
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| { | |
| "idx": 13, | |
| "version": "7", | |
| <<<<<<< HEAD | |
| "when": 1768162667947, | |
| "tag": "0013_brown_gamora", | |
| ======= | |
| "when": 1767697281389, | |
| "tag": "0013_low_roughhouse", | |
| "breakpoints": true | |
| }, | |
| { | |
| "idx": 14, | |
| "version": "7", | |
| "when": 1768045270184, | |
| "tag": "0014_dapper_kang", | |
| "breakpoints": true | |
| }, | |
| { | |
| "idx": 15, | |
| "version": "7", | |
| "when": 1768166276337, | |
| "tag": "0015_glamorous_eternity", | |
| >>>>>>> b30415e (feat(auth): add email verification, password reset, and improved auth UX) | |
| "breakpoints": true | |
| }, | |
| { | |
| "idx": 14, | |
| "version": "7", | |
| "when": 1768304911639, | |
| "tag": "0014_steep_kabuki", | |
| "breakpoints": true | |
| } | |
| ] | |
| { | |
| "idx": 13, | |
| "version": "7", | |
| "when": 1767697281389, | |
| "tag": "0013_low_roughhouse", | |
| "breakpoints": true | |
| }, | |
| { | |
| "idx": 14, | |
| "version": "7", | |
| "when": 1768045270184, | |
| "tag": "0014_dapper_kang", | |
| "breakpoints": true | |
| }, | |
| { | |
| "idx": 15, | |
| "version": "7", | |
| "when": 1768166276337, | |
| "tag": "0015_glamorous_eternity", | |
| "breakpoints": true | |
| } | |
| ] |
🧰 Tools
🪛 Biome (2.1.2)
[error] 98-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: unexpected character <
(parse)
[error] 99-99: expected , but instead found HEAD
Remove HEAD
(parse)
[error] 100-100: expected , but instead found "when"
Remove "when"
(parse)
[error] 100-100: expected , but instead found :
Remove :
(parse)
[error] 100-100: expected , but instead found 1768162667947
Remove 1768162667947
(parse)
[error] 101-101: expected , but instead found :
Remove :
(parse)
[error] 101-101: expected , but instead found "0013_brown_gamora"
Remove "0013_brown_gamora"
(parse)
[error] 101-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 102-102: unexpected character =
(parse)
[error] 103-103: expected , but instead found "when"
Remove "when"
(parse)
[error] 103-103: expected , but instead found :
Remove :
(parse)
[error] 103-103: expected , but instead found 1767697281389
Remove 1767697281389
(parse)
[error] 104-104: expected , but instead found :
Remove :
(parse)
[error] 104-104: expected , but instead found "0013_low_roughhouse"
Remove "0013_low_roughhouse"
(parse)
[error] 105-105: expected , but instead found :
Remove :
(parse)
[error] 105-105: expected , but instead found true
Remove true
(parse)
[error] 106-106: expected , but instead found }
Remove }
(parse)
[error] 106-106: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 107-113: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 113-113: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 114-118: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 118-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: unexpected character >
(parse)
[error] 119-119: String values must be double quoted.
(parse)
[error] 119-119: unexpected character (
(parse)
[error] 119-119: String values must be double quoted.
(parse)
[error] 119-119: unexpected character (
(parse)
[error] 119-119: String values must be double quoted.
(parse)
[error] 119-119: unexpected character )
(parse)
[error] 119-119: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 119-119: unexpected character )
(parse)
[error] 120-120: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 120-120: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 120-120: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 121-121: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
[error] 122-128: End of file expected
Use an array for a sequence of values: [1, 2]
(parse)
This PR performs a controlled baseline reset of Drizzle migrations to resolve migration history corruption caused by parallel migration generation across multiple branches.
Production is treated as the single source of truth, and a new clean baseline migration is introduced to restore a linear, reliable migration history.
Background / Problem
Over time, multiple developers generated migrations in parallel, which resulted in:
• Multiple migration files sharing the same index (0013, 0014, 0015)
• Divergent local and production migration states
• Conflicts in drizzle/meta/_journal.json
• Inability to reliably bootstrap fresh environments
• Risk of silent schema drift
At this point, the migration history was no longer linear or trustworthy, and could not be safely repaired by reordering or deleting individual files.
What was done
• email_verification_tokens table was found to be incorrect in prod
• Table was empty and not relied upon
• Dropped and recreated with the correct structure (token, user_id, expires_at, created_at)
• All historical Drizzle migrations were archived
• A new baseline migration (0000_*) was generated from the production schema
• Baseline was validated by applying it to a clean local database
• Baseline migration hash was inserted into drizzle.__drizzle_migrations
• Ensures production does not attempt to re-run baseline SQL
• New migration history is clean and strictly linear
• Schema files now match production exactly
• Future migrations can proceed safely
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.