Add parent key to Mailbox schema

Bug: 2028418
Change-Id: I79d48befe7754692a3cab6c8851105bb399431f5
This commit is contained in:
Andy Stadler 2011-03-01 10:45:50 -08:00
parent bfb76aa224
commit 3a58509b2a
4 changed files with 23 additions and 2 deletions

View File

@ -321,6 +321,7 @@ public class MessagingController implements Runnable {
box.mDisplayName = remoteNameToAdd;
// box.mServerId;
// box.mParentServerId;
// box.mParentKey;
box.mAccountKey = account.mId;
box.mType = LegacyConversions.inferMailboxTypeFromName(
mContext, remoteNameToAdd);

View File

@ -110,7 +110,8 @@ public class EmailProvider extends ContentProvider {
// Version 14: Add snippet to Message table
// Version 15: Fix upgrade problem in version 14.
// Version 16: Add accountKey to Attachment table
public static final int DATABASE_VERSION = 16;
// Version 17: Add parentKey to Mailbox table
public static final int DATABASE_VERSION = 17;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@ -550,6 +551,7 @@ public class EmailProvider extends ContentProvider {
+ MailboxColumns.DISPLAY_NAME + " text, "
+ MailboxColumns.SERVER_ID + " text, "
+ MailboxColumns.PARENT_SERVER_ID + " text, "
+ MailboxColumns.PARENT_KEY + " integer, "
+ MailboxColumns.ACCOUNT_KEY + " integer, "
+ MailboxColumns.TYPE + " integer, "
+ MailboxColumns.DELIMITER + " integer, "
@ -932,6 +934,16 @@ public class EmailProvider extends ContentProvider {
}
oldVersion = 16;
}
if (oldVersion == 16) {
try {
db.execSQL("alter table " + Mailbox.TABLE_NAME
+ " add column " + Mailbox.PARENT_KEY + " integer;");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
Log.w(TAG, "Exception upgrading EmailProvider.db from 16 to 17 " + e);
}
oldVersion = 17;
}
}
@Override

View File

@ -2158,6 +2158,8 @@ public abstract class EmailContent {
public static final String SERVER_ID = "serverId";
// The server's identifier for the parent of this mailbox (null = top-level)
public static final String PARENT_SERVER_ID = "parentServerId";
// A foreign key for the parent of this mailbox (-1 = top-level, 0=uninitialized)
public static final String PARENT_KEY = "parentKey";
// A foreign key to the Account that owns this mailbox
public static final String ACCOUNT_KEY = "accountKey";
// The type (role) of this mailbox
@ -2196,6 +2198,7 @@ public abstract class EmailContent {
public String mDisplayName;
public String mServerId;
public String mParentServerId;
public long mParentKey;
public long mAccountKey;
public int mType;
public int mDelimiter;
@ -2223,13 +2226,14 @@ public abstract class EmailContent {
public static final int CONTENT_FLAGS_COLUMN = 12;
public static final int CONTENT_VISIBLE_LIMIT_COLUMN = 13;
public static final int CONTENT_SYNC_STATUS_COLUMN = 14;
public static final int CONTENT_PARENT_KEY_COLUMN = 15;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, MailboxColumns.DISPLAY_NAME, MailboxColumns.SERVER_ID,
MailboxColumns.PARENT_SERVER_ID, MailboxColumns.ACCOUNT_KEY, MailboxColumns.TYPE,
MailboxColumns.DELIMITER, MailboxColumns.SYNC_KEY, MailboxColumns.SYNC_LOOKBACK,
MailboxColumns.SYNC_INTERVAL, MailboxColumns.SYNC_TIME,
MailboxColumns.FLAG_VISIBLE, MailboxColumns.FLAGS, MailboxColumns.VISIBLE_LIMIT,
MailboxColumns.SYNC_STATUS
MailboxColumns.SYNC_STATUS, MailboxColumns.PARENT_KEY
};
private static final String ACCOUNT_AND_MAILBOX_TYPE_SELECTION =
@ -2361,6 +2365,7 @@ public abstract class EmailContent {
mDisplayName = cursor.getString(CONTENT_DISPLAY_NAME_COLUMN);
mServerId = cursor.getString(CONTENT_SERVER_ID_COLUMN);
mParentServerId = cursor.getString(CONTENT_PARENT_SERVER_ID_COLUMN);
mParentKey = cursor.getLong(CONTENT_PARENT_KEY_COLUMN);
mAccountKey = cursor.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
mType = cursor.getInt(CONTENT_TYPE_COLUMN);
mDelimiter = cursor.getInt(CONTENT_DELIMITER_COLUMN);
@ -2380,6 +2385,7 @@ public abstract class EmailContent {
values.put(MailboxColumns.DISPLAY_NAME, mDisplayName);
values.put(MailboxColumns.SERVER_ID, mServerId);
values.put(MailboxColumns.PARENT_SERVER_ID, mParentServerId);
values.put(MailboxColumns.PARENT_KEY, mParentKey);
values.put(MailboxColumns.ACCOUNT_KEY, mAccountKey);
values.put(MailboxColumns.TYPE, mType);
values.put(MailboxColumns.DELIMITER, mDelimiter);

View File

@ -126,6 +126,7 @@ public class ProviderTestUtils extends Assert {
box.mDisplayName = name;
box.mServerId = "serverid-" + name;
box.mParentServerId = "parent-serverid-" + name;
box.mParentKey = 4;
box.mAccountKey = accountId;
box.mType = type;
box.mDelimiter = 1;
@ -349,6 +350,7 @@ public class ProviderTestUtils extends Assert {
assertEquals(caller + " mDisplayName", expect.mDisplayName, actual.mDisplayName);
assertEquals(caller + " mServerId", expect.mServerId, actual.mServerId);
assertEquals(caller + " mParentServerId", expect.mParentServerId, actual.mParentServerId);
assertEquals(caller + " mParentKey", expect.mParentKey, actual.mParentKey);
assertEquals(caller + " mAccountKey", expect.mAccountKey, actual.mAccountKey);
assertEquals(caller + " mType", expect.mType, actual.mType);
assertEquals(caller + " mDelimiter", expect.mDelimiter, actual.mDelimiter);