Open kevin-haynie opened 1 year ago
@kevin-haynie Yes, it makes sense to add IF NOT EXISTS for indexes, maybe as option. But I'm not sure I fully understand why the table is not created without it....
You're right, the table will be created without it but when any of the create index statements is attempted for pre-existing tables, it fails and throws an exception. I would like to avoid this exception since it's not really an error when we try to create an index when it already exists.
@kevin-haynie how did you manage to call tje onCreate directly ?
What is the best way to add a table to an existing database? Right now, if I add a new entity, model, DAO that's fine but Floor will never create my new table.
I can call your onCreate method directly and it almost works except for the fact that you create
CREATE INDEX
statements which unfortunately do not includeIF NOT EXISTS
. TheIF NOT EXISTS
clause is included for everything else including tables and views.To me, it seems that Floor should automatically attempt to ensure that all entities are created in the DB. We shouldn't have to write a migration routine just to create a brand new table.
Thoughts?