push keeps wanting to truncate my existing table data
As i develop locally i often want to push a db change with push:pg and instead of just updating the change it wants to recreate thew whole db and delete all content! how can i get it to just do an incremental migration?
3 Replies
above is my code in schema.ts, the comment block explains the issue
Hi. If you have existing tables, there is a
drizzle-kit introspect:pg
(https://orm.drizzle.team/kit-docs/commands#introspect--pull), that lets you pull DDL from existing database and generate schema.ts
from it. I think only then you can move on and apply your changes to your schema.ts
. I'm pretty sure that drizzle would first need to "get to know" your current database schema to be able to perform changes to it.Drizzle ORM - List of commands
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
ive done the introspect, and that's where the above code comes from
after the introspect i do a push and it wants to delete the contents of the existing data, it makes no sense
got it. i have to keep the schema.ts in the drizzle folder. i was deleting it after the introspect. thanks!