Closed IsaiahByDayah closed 4 years ago
Hey @IsaiahByDayah, I'm glad you find it useful! Aside from the very basic tests in this repo, I don't have any examples, so if you'd like to set up a project, I'd gladly link to it in the README.
While I'm no longer working on the product that inspired fireway
, I can describe our workflow.
v0.0.0__some-description.js
--dryrun
flag until we felt comfortable/fireway/
Firestore collection, then rerun the migration. Everything was also roll-forward, so if there was a formatting error in prod, we'd simply write another migration to correct it.That's what worked for us. Hope that's helpful.
Yes! This is extremely helpful. Thanks for clarifying things a bit more here.
Did you ever run into any race-condition issues? Like running a migration on prod when users may have been adding/removing data? I assume you could run transactions/batches in the migration but you still may miss any newly added documents no? Would you lock down clients somehow on deploys/migrations?
Just more poking around to try and cover all my bases with an approach like this and making sure I at least consider any potential bumps. Thanks again!
Good question. Let's use an example:
Let's say you write a migration to rename first_name to firstName
onUpdate
was triggered on a document with first_name
, update firstName
too. We stopped using this strategy after we moved almost everything to a single collection (this made everything much more flexible).
2) Cloud Functions - We ultimately sent all write (and eventually, non-realtime read) operations through a web api. This allowed us to update/write firstName
if first_name
was updated and vice versa. We released the api before the migration. This setup also enabled more complex auth strategies. We moved the api to Cloud Run after getting tired of the Cloud Function cold starts.By handling the scenario of outdated clients, we avoided migration race conditions.
Ahhh, ok. That makes a lot of sense. I've been toying with the idea of doing all writes via a web API for similar reasons so hearing that you guys also found that to be beneficial helps.
Awesome. Thanks again for sharing how you tackled some of these problems. I think it'll def help me with things in my project!
Happy to help! You’ll also find that an api for mutations allows you to create document ids on the server, instead of allowing users to create any id they want on the client.
Good luck with your project.
Hey @kevlened, I really love that you've solved a problem I (and I imagine many others) have found ourselves with. I was wondering if you had an open-source project to show how this actually looks in practice (for example: how to handle failed migration data rollbacks, formatting longer descriptions in the migration filename, etc).
More than happy to help set up a skeleton project if that would help, but I wanted to see if you had something open already to look at. Thanks