probably an uber noob question but I have an exist...
# orm-help
r
probably an uber noob question but I have an existing pg db and when I run
npx prisma migrate dev --name init
it tries to add fields to one of the tables and warns all data will be lost, I don't want that... What am I missing? many TIA! In my schema I'm db-pulling to get the two tables into prisma.schema and then adding a third new one.
[+] Added tables
- job
- job_schedule
`[*] Changed the
job_schedule
table`
[+] Added index on columns (job_id)
[+] Added foreign key on columns (job_id)
√ We need to reset the PostgreSQL database "My-Project" at "XX.XXX.XXX.XX:5432".
Do you want to continue? All data will be lost. ... no
a
the migrate dev command is pretty destructive by default
if it senses that your schema and your database are out of sync it'll prefer to drop your database and rebuild
the idea is that, in dev, you're building something with seed scripts etc., where your data isn't that important and can go through that
There's a different pathway for prod, in theory you could use that approach even in a dev database to prevent the destructive migration
r
@Austin Zentz thx! My client has an existing database. I have a schema.prisma that represents what I need table-wise. I don't have any migrations to apply. What do you advise?
finally got it
Your database is now in sync with your schema. Done in 2.71s
✔ Generated Prisma Client (3.12.0 | library) to .\node_modules\@prisma\client in 104ms
n
Hey Rob 👋 Do you mean that prisma db pull was adding constraints which weren’t defined in the database?
r
@Nurul nope, disregard.
👍 1