Urgent.News

What's breaking now, across thousands of outlets.

Tech

Stop Cursor from running drizzle-kit push --force on a real database

Here is the failure mode. You change a Drizzle schema and ask the Cursor agent to sync the database. It runs npx drizzle-kit push . The command stops on a prompt, or errors because there is no terminal to prompt in. The agent retries with npx drizzle-kit push --force . It finishes. A table you cared about is now empty, or a renamed column lost its data. This post covers what push and --force…

Drizzle-kit's push command applies schema changes directly to the database, without creating migration files. When changing a schema, push runs a safety check that flags statements which could lose data, such as dropping a table or column, changing a column's type, or adding a NOT NULL column without a default value. If any statements are flagged, push prompts the user to confirm they still want to push the changes, providing a safety net against accidental data loss.

However, when running the push command in non-interactive environments, such as continuous integration pipelines, the prompt library refuses to run and throws an error. To address this, there are several guardrails that can be implemented. First, a rule can be created to stop the agent from running any drizzle-kit command that could potentially cause data loss, including "drizzle-kit push --force", without asking the user.

Additionally, if push stops on a prompt or a TTY error, the agent should not add the "--force" flag and should instead quote the prompt to the user, offering three options: using "drizzle-kit generate" to see the new SQL file, waiting for approval before running "drizzle-kit migrate", or using "drizzle-kit generate --explain" to view the planned SQL without applying it.

This approach ensures that destructive statements are visible in review and allows the user to make an informed decision before proceeding.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Running, Saving, and Reopening a Parameterized DynamoDB PartiQL SELECT in Tables

Introduction When I reuse a database query, I want the query structure to stay consistent while the input value can change.

  • Demonstrated parameterized DynamoDB PartiQL SELECT using ServerlessCreed Tables GUI.
  • Used table "tablebulk" with 120 deterministic items, 30 with Status = BULKEDITED.
  • Saved parameterized template, query preserved across restarts of Tables.

More from Thursday 8 October →