From ed832f9545b14295d364950675b97d2670a37826 Mon Sep 17 00:00:00 2001 From: Andy2 Date: Sat, 6 Aug 2011 19:26:36 -0700 Subject: [PATCH] update database from any version, not just two adjoining. --- .../src/org/eehouse/android/xw4/DBHelper.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java index 7bb4ff7d3..f6fbbee82 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java @@ -123,24 +123,28 @@ public class DBHelper extends SQLiteOpenHelper { { Utils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion ); - if ( newVersion == 6 && oldVersion == 5 ) { + switch( oldVersion ) { + case 5: onCreateObits(db); - } else if ( newVersion == 7 && oldVersion == 6 ) { + case 6: db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM + " ADD COLUMN " + TURN + " INTEGER;" ); db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM + " ADD COLUMN " + GIFLAGS + " INTEGER;" ); db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM + " ADD COLUMN " + CHAT_HISTORY + " TEXT;" ); - } else if ( newVersion == 8 && oldVersion == 7 ) { + case 7: db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM + " ADD COLUMN " + MISSINGPLYRS + " INTEGER;" ); - } else if ( newVersion == 9 && oldVersion == 8 ) { + case 8: db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM + " ADD COLUMN " + GAME_NAME + " TEXT;" ); db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM + " ADD COLUMN " + CONTRACTED + " INTEGER;" ); - } else { + case 9: + // nothing yet + break; + default: db.execSQL( "DROP TABLE " + TABLE_NAME_SUM + ";" ); if ( oldVersion >= 6 ) { db.execSQL( "DROP TABLE " + TABLE_NAME_OBITS + ";" );