Migrations: Default for auto fill-in #92
Replies: 3 comments 2 replies
-
Glad you've enjoyed using Triplit so far! Yeah that's great idea. We're planning to add some basic automatic data migrations that you can optionally apply after getting an error message from |
Beta Was this translation helpful? Give feedback.
-
Thank you for the detailed info! I agree that some changes, which could be automatically generated, still need manual approval. However I have some concerns regarding the currently proposed migration pattern:
This seems almost impossible to comply with for a local first distributed system. There might be clients that do not come back online for weeks, which would mean completing migrations would take a very long time in which the dev team still has to consider how on-going migrations might impact app logic. Also what if you want to start another migration while the previous one is still ongoing? This seems to get messy fast. Of course you could use a "cut off" date after which old clients are simply dismissed, but from the user perspective, being not able to sync data any more (rendering the app basically useless for network usage) only because they haven't opened it for a month, seems -especially for lo-fi - unacceptable. Schema Versioning & MigrationsI'm wondering if instead the traditional up/down deterministic migration logic, as used by migration tools like TypeORM etc, would not be the better pattern - especially for lofi. Define a migration with 'up' which holds the new schema plus all code that needs to run to make the db compliant with the new schema. (In triplit's case, even just an upwards transition could be needed since clients can update themselves). These can be collected in a migration file, that the server can check against with the client schema version. Now, all clients, no matter their offline time, they can still upgrade their database and submit the new update. Also, as devs we certainly feel much more relaxed knowing that we don't have to continuously monitor how many clients have yet migrated to declare a migration as "finished" at an more or less arbitrary cut-off date. Scenario:
|
Beta Was this translation helpful? Give feedback.
-
You're exactly right to call out all of these details! It's a challenging problem that doesn't have any "free lunch" like running a single node database.
This is an unfortunate, intractable truth of distributed systems. The best solution is to maintain backwards compatibility at all times. We're working on tooling to make this easier to manage in your code but it's only the way to guarantee that older clients can continue to operate. This is why we warn against backwards incompatible changes and don't make any on your behalf. In development it's fine and we'll continue to streamline that flow but in production you're better of making some additive change to your schema and data instead.
This mostly works and something like this will likely be part of our solution to making your schema code simpler as it evolves but the main issue is that older clients can't simply migrate their schemas to a backwards incompatible version without also updating client code like queries and mutations. So in a sense this pattern would require keeping all client's code perfectly up to date which as you've pointed out is impossible with some clients being offline for long periods of time.
It's still very early so not ready to speak to our solution quite yet but my hunch is that this can be fully automated. |
Beta Was this translation helpful? Give feedback.
-
Hey team,
Great first impression, especially local-first, relationships defined as queries and access control in schemas!
Looking at migrations
I was wondering if the default of a schema can not be simply used to fill new optional attributes automatically ?
Would make migrations way more streamlined.
Beta Was this translation helpful? Give feedback.
All reactions