Review and Apply Database Migrations
Generate a schema change with Bhai, review the SQL, and apply it to a development database with the right tooling.
A migration records a database schema change in SQL so you can apply the same change to another environment. Ask Bhai to draft one when a feature needs a new table, column, or relationship. A generated file isn’t proof that the database changed. Check the result on the database your application actually uses.
Review the change in development
Describe the data model
Tell Bhai what you’re changing and which database engine the project uses. Ask for an incremental migration that follows your project’s history. A Drizzle project might put the next change in drizzle/0002_add_user_roles.sql.
Check the generated SQL
Read the file before applying it to a database with data you need. Check that the column types fit existing records and that foreign keys refer to the intended tables and columns. For a new required field, verify how the migration handles rows that don’t yet have a value.
Apply it to the development database
Use your project’s migration tool with its development connection, and verify the result by querying the changed table. Studio can report a migration failure when no isolated database target is attached. If that happens, configure your database and use your migration tool to apply the file. Don’t assume the migration ran because the SQL appeared in chat.
Check the application types
Update or regenerate the TypeScript types if your tooling doesn’t do so. Run the code paths that use the changed fields, then use the reviewed migration for the next environment.
Choose the tooling your project already uses
| Tool | What to use it for |
|---|---|
| Drizzle ORM | The default choice for typed queries and TypeScript schema definitions in edge and serverless projects. Match the schema helpers to SQLite or Postgres. |
| Prisma | A type-safe client and schema tooling for Prisma projects. Use Prisma Studio to inspect records after you apply a change. |
| Raw SQL | Use versioned SQL to change a schema and parameterized SQL for application queries that need a custom shape or optimization. |
A successful query in the in-browser preview doesn’t update the schema of a deployed database. Check your connection target before trusting the result.