/** * Executes the migration in the database. If <code>up</code> is set to <code>true</code>, then * the method {@link Migration#up()} will be called. Otherwise, the method {@link * Migration#down()} will get called. * * @param m The migration to run. * @param up If <code>true</code>, it will upgrade. Otherwise, it will downgrade. */ private static void runMigration(Migration m, boolean up) { SQLiteDatabase db = configuration.getDatabase(); db.beginTransaction(); try { if (up) { m.up(); markAsMigrated(m); } else { m.down(); migrationDao.delete(m.getMigration()); } db.setTransactionSuccessful(); } catch (Exception e) { Logger.e("Exception when migrating " + m.getClass().getName(), e); } finally { db.endTransaction(); } }