-
Notifications
You must be signed in to change notification settings - Fork 26
Implement Display of Destructive Changes #146
Comments
I have created a specs issue about this topic. |
@mavilein do we receive enough information here to also show a diff? |
@matthewmueller : No. Currently it is just a plain String describing the data loss. What kind of diff would you like to show? |
Thanks, I'll formalize this more, but quick stream of thoughts on what I'd propose: Delete a model: - model User {
- id Int @id
- firstName String
- lastName String
- @unique([firstName, lastName], name: "fullName")
- } Rename a field + update an attribute: model User {
id Int @id
- firstName String
+ givenName String
lastName String
~ @unique([givenName, lastName], name: "fullName")
} We may have this information already on the client, but if not, it probably makes sense to send it |
@matthewmueller : How are your proposals related to destructive changes? I think we have this kind of data model diffing in the CLI already. A deleted field might not lead to data loss at all hence i don't see how this moves this forward. |
I originally had a confirmation dialog with an
How are these messages obtained? It feels like it would be slow to learn some of this and halting the developer flow to save a migration seems iffy. |
@matthewmueller : What do you mean with |
@mavilein for example:
I'm assuming this would do something like: select count(name) from User where name is not null If that's the case, could that get really slow on large datasets? And if you're making sweeping changes, it could require N queries for N changes. I'm trying to get a gauge of how slow this could be when I type |
@matthewmueller : Yes this is what we do. I think this is a valid concern. We have not had problems with this approach in Prisma 1 though. |
* Add a Studio class to handle communication with @prisma/studio-server * Add a StudioCommand class * Use this new Studio class in Lift's main class * Remove getDatamodelPath from Lift's main class and use the new utility * Remove `datamodel` param from `recreateStudioServer` since it is not required by StudioServer anymore. * Use fs.existsSync instead of fs.stat * 0.3.55 [skip ci] * add destructive changes ui for dev. Closes #146 * 0.3.56 [skip ci] * 0.3.57 [skip ci] * fix auto approve * 0.3.58 [skip ci] * Use this new Studio class in Lift's main class * Remove getDatamodelPath from Lift's main class and use the new utility * Remove occupyPath from StudioCommand
The migration engine has now implemented support for checking for destructive changes. The output of
applyMigration
can now return a non empty array in thewarnings
property. If that is the case the CLI must send theforce
parameter as true so the user acknowledges the destructive change.The JSON for warnings looks like this:
Note: The migration engine currently ignores the
force
flag and applies the migration even if there are destructive changes. This is temporary until the CLI has implemented support for this and we can enable the proper behavior.The text was updated successfully, but these errors were encountered: