Loading app/core/src/main/java/com/fsck/k9/mailstore/LockableDatabase.java +3 −0 Original line number Diff line number Diff line Loading @@ -378,6 +378,9 @@ public class LockableDatabase { } doOpenOrCreateDb(databaseFile); } mDb.execSQL("PRAGMA foreign_keys = ON;"); if (mDb.getVersion() != mSchemaDefinition.getVersion()) { mSchemaDefinition.doDbUpgrade(mDb); } Loading app/storage/src/main/java/com/fsck/k9/storage/StoreSchemaDefinition.java +9 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import timber.log.Timber; class StoreSchemaDefinition implements SchemaDefinition { static final int DB_VERSION = 67; static final int DB_VERSION = 68; private final MigrationsHelper migrationsHelper; Loading Loading @@ -209,6 +209,14 @@ class StoreSchemaDefinition implements SchemaDefinition { "UPDATE threads SET root=id WHERE root IS NULL AND ROWID = NEW.ROWID; " + "END"); db.execSQL("DROP TABLE IF EXISTS outbox_state"); db.execSQL("CREATE TABLE outbox_state (" + "message_id INTEGER PRIMARY KEY NOT NULL REFERENCES messages(id) ON DELETE CASCADE," + "send_state TEXT," + "number_of_send_attempts INTEGER DEFAULT 0," + "error_timestamp INTEGER DEFAULT 0," + "error TEXT)"); db.execSQL("DROP TABLE IF EXISTS pending_commands"); db.execSQL("CREATE TABLE pending_commands " + "(id INTEGER PRIMARY KEY, command TEXT, data TEXT)"); Loading app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo68.kt 0 → 100644 +31 −0 Original line number Diff line number Diff line package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase internal object MigrationTo68 { @JvmStatic fun addOutboxStateTable(db: SQLiteDatabase) { createOutboxStateTable(db) createOutboxStateEntries(db) } private fun createOutboxStateTable(db: SQLiteDatabase) { db.execSQL("CREATE TABLE outbox_state (" + "message_id INTEGER PRIMARY KEY NOT NULL REFERENCES messages(id) ON DELETE CASCADE," + "send_state TEXT," + "number_of_send_attempts INTEGER DEFAULT 0," + "error_timestamp INTEGER DEFAULT 0," + "error TEXT)") } private fun createOutboxStateEntries(db: SQLiteDatabase) { db.execSQL(""" INSERT INTO outbox_state (message_id, send_state) SELECT messages.id, 'ready' FROM folders JOIN messages ON (folders.id = messages.folder_id) WHERE folders.server_id = 'K9MAIL_INTERNAL_OUTBOX' """.trimIndent() ) } } app/storage/src/main/java/com/fsck/k9/storage/migrations/Migrations.java +2 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,8 @@ public class Migrations { MigrationTo66.addEncryptionTypeColumnToMessagesTable(db); case 66: MigrationTo67.addTypeColumnToFoldersTable(db, migrationsHelper); case 67: MigrationTo68.addOutboxStateTable(db); } if (shouldBuildFtsTable) { Loading Loading
app/core/src/main/java/com/fsck/k9/mailstore/LockableDatabase.java +3 −0 Original line number Diff line number Diff line Loading @@ -378,6 +378,9 @@ public class LockableDatabase { } doOpenOrCreateDb(databaseFile); } mDb.execSQL("PRAGMA foreign_keys = ON;"); if (mDb.getVersion() != mSchemaDefinition.getVersion()) { mSchemaDefinition.doDbUpgrade(mDb); } Loading
app/storage/src/main/java/com/fsck/k9/storage/StoreSchemaDefinition.java +9 −1 Original line number Diff line number Diff line Loading @@ -12,7 +12,7 @@ import timber.log.Timber; class StoreSchemaDefinition implements SchemaDefinition { static final int DB_VERSION = 67; static final int DB_VERSION = 68; private final MigrationsHelper migrationsHelper; Loading Loading @@ -209,6 +209,14 @@ class StoreSchemaDefinition implements SchemaDefinition { "UPDATE threads SET root=id WHERE root IS NULL AND ROWID = NEW.ROWID; " + "END"); db.execSQL("DROP TABLE IF EXISTS outbox_state"); db.execSQL("CREATE TABLE outbox_state (" + "message_id INTEGER PRIMARY KEY NOT NULL REFERENCES messages(id) ON DELETE CASCADE," + "send_state TEXT," + "number_of_send_attempts INTEGER DEFAULT 0," + "error_timestamp INTEGER DEFAULT 0," + "error TEXT)"); db.execSQL("DROP TABLE IF EXISTS pending_commands"); db.execSQL("CREATE TABLE pending_commands " + "(id INTEGER PRIMARY KEY, command TEXT, data TEXT)"); Loading
app/storage/src/main/java/com/fsck/k9/storage/migrations/MigrationTo68.kt 0 → 100644 +31 −0 Original line number Diff line number Diff line package com.fsck.k9.storage.migrations import android.database.sqlite.SQLiteDatabase internal object MigrationTo68 { @JvmStatic fun addOutboxStateTable(db: SQLiteDatabase) { createOutboxStateTable(db) createOutboxStateEntries(db) } private fun createOutboxStateTable(db: SQLiteDatabase) { db.execSQL("CREATE TABLE outbox_state (" + "message_id INTEGER PRIMARY KEY NOT NULL REFERENCES messages(id) ON DELETE CASCADE," + "send_state TEXT," + "number_of_send_attempts INTEGER DEFAULT 0," + "error_timestamp INTEGER DEFAULT 0," + "error TEXT)") } private fun createOutboxStateEntries(db: SQLiteDatabase) { db.execSQL(""" INSERT INTO outbox_state (message_id, send_state) SELECT messages.id, 'ready' FROM folders JOIN messages ON (folders.id = messages.folder_id) WHERE folders.server_id = 'K9MAIL_INTERNAL_OUTBOX' """.trimIndent() ) } }
app/storage/src/main/java/com/fsck/k9/storage/migrations/Migrations.java +2 −0 Original line number Diff line number Diff line Loading @@ -92,6 +92,8 @@ public class Migrations { MigrationTo66.addEncryptionTypeColumnToMessagesTable(db); case 66: MigrationTo67.addTypeColumnToFoldersTable(db, migrationsHelper); case 67: MigrationTo68.addOutboxStateTable(db); } if (shouldBuildFtsTable) { Loading