-
Is there a supported or third party solution to verify that the schema defined in code and the one we connect to at runtime match? Eg. Tables have the correct columns, indices, constraints foreign keys? This would help minimize the risk of pending, missing or incorrect migrations. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
There is currently no built-in way to perform such a schema verification automatically. I'm also not aware of any third party crate that offers this functionality. The currently best way to ensure that your schema is always what you expect is to use the That written we are interested in adding such a verification functionality to diesel at some point so if you are interested in working on this feature we can certainly discuss technical details. |
Beta Was this translation helpful? Give feedback.
-
Sure, but that wouldnt protect against unwritten or incorrect migrations though. I'm not sure i can spend the resources to dive into this currently, but I'll let you know if i do. Maybe start as an independent crate with something small like verify if the columns are all there and take it from there. I'll ping you if i decide to take it on in the future, but that won't happen for a while |
Beta Was this translation helpful? Give feedback.
There is currently no built-in way to perform such a schema verification automatically. I'm also not aware of any third party crate that offers this functionality.
The currently best way to ensure that your schema is always what you expect is to use the
embed_migration!()
macro and then apply the migrations on application startup.That written we are interested in adding such a verification functionality to diesel at some point so if you are interested in working on this feature we can certainly discuss technical details.