Open kalda341 opened 1 year ago
Hi @kalda341, sorry for the late answer, I'm still working on the core of /schema
, I'll be thinking to this topic as soon as the project will be more fleshed out
@gcanti no worries, I know it's not the highest priority. I'm watching your progress with the new packages excitedly!
Hi,
I'm super interested to hear what you have in mind for versioning and migrations in this package, as I have a fairly complex system in production to manage this that I've built on top of
io-ts
. I know this is probably something you don't want to put much thought into at this point, but I'd love to get a discussion started well before you decide on any specific implementation.Briefly, we have a schema version field on a struct which is used to discriminate between versions. We have a set of migrations, which are type checked in order to move from one version to the next (we don't do reverse migrations, though I would like to). After a migration is run from one version to the next we check the type at runtime with io-ts to make sure the result is valid. We can recursively call migrateNext which will take an arbitrary version and migrate it to the latest version.
Below is a bit of a mess (I've taken code from a lot of different places), but may be of interest if you're interested in how this works. I'd love to hear how this compares with what you have in mind. This is designed for a specific schema, though I suspect it could fairly easily be generalised.
Thank you for all your work, I'm very excited to move to using the
fp-ts
org packages soon, though it will be a massive job as we are super heavily invested in the previousfp-ts
,io-ts
andmonocle-ts
packages!