mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
add ctime and mtime timestamps to DB when creating, and upgrade to new
version by adding them. Can't have them default to 'now' because that's not supported for ADDs. Can't remove columns either, so at some point I'll need to migrate to get rid of accumulated cruft. Timestamps are not set nor read yet.
This commit is contained in:
parent
c9fec737e5
commit
465370bac6
1 changed files with 27 additions and 7 deletions
|
@ -29,7 +29,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
public static final String TABLE_NAME_SUM = "summaries";
|
||||
public static final String TABLE_NAME_OBITS = "obits";
|
||||
private static final String DB_NAME = "xwdb";
|
||||
private static final int DB_VERSION = 6;
|
||||
private static final int DB_VERSION = 7;
|
||||
|
||||
public static final String FILE_NAME = "FILE_NAME";
|
||||
public static final String NUM_MOVES = "NUM_MOVES";
|
||||
|
@ -52,9 +52,10 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
public static final String SEED = "SEED";
|
||||
public static final String SMSPHONE = "SMSPHONE";
|
||||
// not used yet
|
||||
public static final String CREATE_TIME = "CREATE_TIME";
|
||||
// public static final String CREATE_TIME = "CREATE_TIME";
|
||||
public static final String CTIME = "CTIME";
|
||||
// not used yet
|
||||
public static final String LASTPLAY_TIME = "LASTPLAY_TIME";
|
||||
public static final String MTIME = "MTIME";
|
||||
|
||||
|
||||
public DBHelper( Context context )
|
||||
|
@ -85,8 +86,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
// HASMSGS: sqlite doesn't have bool; use 0 and 1
|
||||
+ HASMSGS + " INTEGER DEFAULT 0,"
|
||||
|
||||
+ CREATE_TIME + " INTEGER,"
|
||||
+ LASTPLAY_TIME + " INTEGER,"
|
||||
+ CTIME + " TIMESTAMP,"
|
||||
+ MTIME + " TIMESTAMP,"
|
||||
|
||||
// + CREATE_TIME + " INTEGER,"
|
||||
// + LASTPLAY_TIME + " INTEGER,"
|
||||
|
||||
+ SNAPSHOT + " BLOB"
|
||||
+ ");" );
|
||||
|
@ -112,8 +116,24 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
{
|
||||
Utils.logf( "onUpgrade: old: %d; new: %d", oldVersion, newVersion );
|
||||
|
||||
if ( newVersion == 6 && oldVersion == 5 ) {
|
||||
onCreateObits(db);
|
||||
if ( newVersion == 7 ) {
|
||||
switch( oldVersion ) {
|
||||
case 5:
|
||||
onCreateObits( db );
|
||||
// FALLTHRU
|
||||
case 6:
|
||||
// F*cking sqlite won't let me add a column with a
|
||||
// non-constant default (i.e. DEFAULT
|
||||
// (datetime('now','localtime'))," so I'll have to add
|
||||
// the value manually. Or screw everybody and nuke
|
||||
// the DB rather than modify it. I want my
|
||||
// postgres...
|
||||
db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM +
|
||||
" ADD " + CTIME + " TIMESTAMP;" );
|
||||
db.execSQL( "ALTER TABLE " + TABLE_NAME_SUM
|
||||
+ " ADD " + MTIME + " TIMESTAMP;" );
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
db.execSQL( "DROP TABLE " + TABLE_NAME_SUM + ";" );
|
||||
if ( oldVersion >= 6 ) {
|
||||
|
|
Loading…
Reference in a new issue