GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — v0.6.54: migration error logs by icecrasher321 · Pull Request #4261 · simstudioai/sim

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

improvement(migrations): log better errors (#4260)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@icecrasher321
improvement(migrations): log better errors (#4260)
41a1b50
@vercel

vercel Bot commented Apr 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 22, 2026 5:09am

Request Review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cursor

cursor Bot commented Apr 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches database migrations and index/constraint ordering; while the change is small, it affects schema invariants during data migration and could impact production migration behavior if assumptions differ.

Overview
Improves the 0194 permission-group rebase migration by dropping the legacy permission_group_member_user_id_unique index earlier (before cloning) to prevent unique-constraint violations while inserting per-workspace membership clones.

Updates packages/db/scripts/migrate.ts to log richer Postgres error diagnostics (PG code, constraint/table/column, failing query/parameters, nested causes, and stack) instead of only printing error.message.

Reviewed by Cursor Bugbot for commit 41a1b50. Configure here.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes two targeted improvements to the migration infrastructure: it moves the DROP INDEX for permission_group_member_user_id_unique from step 7 to step 1c in migration 0194 so the legacy global uniqueness constraint is removed before the cloning INSERT in step 4 (which would otherwise violate it), and it replaces the bare error.message log in migrate.ts with a printMigrationError helper that surfaces all Postgres driver diagnostic fields — constraint name, PG error code, hint, failing query, cause chain, and stack trace — making future migration failures much easier to diagnose.

Confidence Score: 5/5

Safe to merge — both changes are correct, well-documented, and idempotent.

The SQL reordering fixes a real constraint-violation bug that would have caused migration 0194 to fail on databases with multi-workspace users; the DROP INDEX IF EXISTS is idempotent so re-runs are safe. The printMigrationError function is purely additive, handles all error shapes defensively, and the function declaration is correctly hoisted in the ES module scope. No P0/P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
packages/db/migrations/0194_careless_pete_wisdom.sql Moves DROP INDEX on permission_group_member_user_id_unique from step 7 (late cleanup) to step 1c (before cloning), preventing a unique-constraint violation when inserting cloned member rows in step 4.
packages/db/scripts/migrate.ts Replaces single-field error.message logging with a comprehensive printMigrationError function that surfaces all Postgres driver diagnostic fields (code, constraint, hint, query, etc.) on migration failure.

Sequence Diagram

sequenceDiagram
    participant Script as migrate.ts
    participant Drizzle as drizzle-orm migrator
    participant PG as PostgreSQL

    Script->>Drizzle: migrate(drizzle(client), { migrationsFolder })
    Drizzle->>PG: Run migration SQL statements
    alt Migration succeeds
        PG-->>Drizzle: OK
        Drizzle-->>Script: resolved
        Script->>Script: console.log("Migrations applied successfully.")
    else Migration fails
        PG-->>Drizzle: PostgresError (code, constraint, hint, query…)
        Drizzle-->>Script: throws Error
        Script->>Script: printMigrationError(error)
        Note over Script: Logs message, PG fields (code,<br/>constraint, hint, table, etc.),<br/>failing query, parameters,<br/>cause chain, stack
        Script->>Script: process.exit(1)
    end
    Script->>PG: client.end() [finally]
Loading

Reviews (1): Last reviewed commit: "improvement(migrations): log better erro..." | Re-trigger Greptile

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vercel
vercel Bot deployed to Preview April 22, 2026 05:09
View deployment
@icecrasher321
icecrasher321 merged commit 7c619e7 into main Apr 22, 2026
31 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This branch was successfully deployed

1 active deployment
Preview — 41a1b50a Deployed Apr 22, 2026 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@icecrasher321
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.