So I have been working on my mobile app for a while and it is live and in production.
Because we released the app prematurely and are continuously improving current features and making them more thorough it means at every version there's a high change that database schemas will change.
The problem that I have is:
how do I make sure that when 1.3 is released, all the users who still have 1.2 installed on their phone are still able to use the app without problem?
Whenever 1.3 is released, some API endpoint changes and so does the database schema underneath.
So when my mobile app running 1.2 makes a request to api/users/all
:
// Instead of getting data like this:
users = [
{
name: 'John Cena',
category: 'Professor'
},
...
]
// The new data is like this:
[
{
name: 'John Cena',
category_id: 4,
category: {
id: 4,
name: 'Professor',
}
},
...
]
So now my mobile on 1.2 breaks because category
is an object not a string.
I have tried to do research on backward compatibility but the material I find doesn't speak to the problem I have.
Solutions I have found:
- Version your API
- Version your DB schema and run update scripts
I do can add versioning to my API /api/v1.2/users/all
but how does that help me with my data problem?
I have seen mentions of schema versioning or even database version numbers but I'm unsure on how to execute that concept properly.
I don't want to have ausers_v1.2
and users_v1.3
table.
If a new user signs up he will be inserted in users_v1.3
and users on 1.2 won't know of his existence and vice versa. Having different databases as well would be synonymous to the same problem.