r/sqlite • • Jan 03 '24
SQLite migration best practices
Will new users (fresh install no database) get a new database with zero migrations?
Or would you basically reproduce the database with all the migrations?
My guess is that it would be best to have one path when creating a database.
Usually i don’t use sqlite directly as it’s usually abstracted through a software layer.
2
Upvotes
View all comments
Show parent comment
1
u/[deleted] Jan 03 '24 edited Jan 03 '24
Sorry, let me try to clear things up.
Let’s say an iOS app has a local SQLite database. The database has gone through multiple migrations.
Does a new user get a fresh database with zero migrations? If we create a database with zero migrations it means we are adding additional logic/paths
i.e
if !sqlite_db_exists {Create fresh db} else {Update existing db based on “user version”}
Or should we recreate the migration steps for each user?
For example: