ORMLITE: Alter existing table

26 views
Skip to first unread message

Jozef Gľaba

unread,
Sep 22, 2017, 8:00:18 PM9/22/17
to ORMLite Users
Does ORMLite support any way of altering existing table (eg: adding new columns) which is most common way of updating applications.

This can be done only under android:

What about other systems? Desktop app for example?

The only way I found is to create separate connection to database before creating DAO,because creating DAO will fail and there is no other way to execute raw statmetns without DAO..

So you have to connect manually before applying Ormlite, then check for changes and alert database all using raw sql...

So what is the point of ORM then if you need to do all alters manully?

Gray Watson

unread,
Sep 25, 2017, 10:14:58 AM9/25/17
to ORMLite Users
Creating the DAO object should fail if the schema doesn't match. It's when you start doing db transactions is when you might get exceptions.

There are many ways that you could manage your schema changes:

- You could store a database version in some meta table (like android) and then apply schema changes if the version < code version.
- We do a similar thing by store schema changes in numbered files. Whenever our application boots it sees whether all of the schema change numbers have been applied and if not it applies the schema changes in order.

Anyone else have recommendations?
gray
> --
> You received this message because you are subscribed to the Google Groups "ORMLite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ormlite-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages