I'm using ActiveAndroid
in my application as the Database
system. At current stage I don't want to write the migration files for migrating current tables to altered ones for when I update DB version.
Instead what I want to do is to drop all tables and recreate a new set of tables.
Unfortunately from digging in the ActiveAndroid
the Database
version test happens at initialization stage in which I pass a ActiveAndroid
Configuration
object to configure the Database
.
At this point their implementation only checks for migration files in the assets folder. I don't mind to create migrations file to do what I need but the problem is that I don't know how to get the current tables initialized in the DB to recreate them.
Does some one knows how to do that with ActiveAndroid?
Not sure if I understood correctly but if you are in development then the easiest is to just uninstall the app and let Active Android recreate the DB schema when you install it again.
When in production you will need to use the migration scripts as per their documentation.
I faced a similar issue and I needed to force a few tables to be recreated. Unfortunately you will need to do it manually. However you can use the ActiveAndroid helper classes to help you out.
Drop the tables:
SQLiteUtils.execSql("DROP TABLE IF EXISTS Your_Table_Name");
Recreate the table using the ActiveAndroid classes.
SQLiteUtils.execSql(SQLiteUtils.createTableDefinition(Cache.getTableInfo(YOUR_MODEL_CLASS.class)));
Insert the old data into your newwly create table.