PrismaP
Prisma15mo ago
5 replies
ImEgg

Mongodb, Making Breaking changes to production database

Hi, I'm trying to understand what the suggested way or best practices for making breaking changes to a database in production are.

for simplicity sake, let's say I have a schema for mongodb:
model User {
  id        String 
  tenant_id String 
  email     String   @unique
  password  String
  line_one  String
  city      String
  state     String
  zip       String
  @@map("users")
}


where there is already data present.

let's say now I want to be able to have multiple addresses so I want the schema to be put like this:

model User {
  id        String 
  tenant_id String 
  email     String   @unique
  password  String
//assume type is of same fields
  address   Address[] 
  @@map("users")
}

To add the new address field is okay but the moving of existing data from the 4 separate fields to now the new address object is what I am having a hard time understanding how to do.

I'd like to understand how people are doing these types of database changes for mongodb with prisma or just in general I suppose.

thanks!
Was this page helpful?