Post

Say I have a SvelteKit in which most pages can be prerendered and this requires data from the DB. Some pages require the DB live. Now what happens during a deployment? I need to update the DB (if migrations were added) and then update the web application and push the new code. However, since... 1/2

... these steps may require a few mins, data might be inconsistent. The pages that require the DB live already have the new data before the deployment is finished. This might actually crash the application. AI suggests removing the prerendering and using caching instead. Other ideas? 2/2

Is the issue that the database shape changed? In that case, the best practice is to never do hard changes: you should be back compatible in one release, then migrate the data and then hard delete the column (or do the "hard change")

This is the way to go when the schema changes. But I was referring to changes of the data. I have a Wiki style app (will be announced soon ✨) and the information on some pages could be different from the one on other pages, namely when the database update has finished, but the app update not yet.

Specifically, in the deployment pipeline, I first update the remote database (1), then build the application (2), and then deploy it to Netlify (3). Currently it only takes like 2 minutes, but in the time between (1) and (3) the deployed app has inconsistent data.

Assume we have pages P and Q. Both say something about an item X. Suppose P is prerendered and Q is not (for good reasons). Let's make a commit that changes the description of X in the db. Then this description update will be visible on Q a few mins before it will be on P.

In the first post I wrote that the app might crash. This is not the case here, and it can be prevented by using the method you described. But even though it doesn't crash, I wonder if there is a better way to just accept the inconsistency. Without using docker or some complex deployment strategy.

0 reposts0 likes