Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite-Net Extensions - Does the CreateTable function alter my existing tables?

I am using SQLite-net together with the TwinCoders NuGet for extension methods in a MvvmCross Xamarin project. I want to make the database to stay updated even if I will modify the models in future.

My question is: If I use the CreateTable function for creating a SQLite table based on the model and the database already exists on the tablet/phone, but it has a different structure (let's say that the table has a missing column which was added in the last update), will this function alter the existing table? Thanks!

like image 651
Bogdan Avatar asked Oct 30 '22 06:10

Bogdan


1 Answers

Thanks for your answers! SQLite-Net implements automatic migrations indeed. It treats the lack of "ALTER DROP COLUMN" and "ALTER RENAME COLUMN" commands from SQLite as follows:

  • if the name of one column is changed, then a new column will be created with the new name and the old one will be ignored by the queries
  • if the column is dropped, then it will remain in the database, but the queries will ignore it

I didn't try yet what happens when I change the datatype of one column (attribute), but I hope it will not be the case in our project.

like image 64
Bogdan Avatar answered Nov 15 '22 08:11

Bogdan