mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Add back remote deleted column.
This commit is contained in:
@@ -190,6 +190,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
const val UNIDENTIFIED = "unidentified"
|
||||
const val REACTIONS_UNREAD = "reactions_unread"
|
||||
const val REACTIONS_LAST_SEEN = "reactions_last_seen"
|
||||
const val REMOTE_DELETED = "remote_deleted" // Note: Use [DELETED_BY] instead. All attempts to remove this have failed.
|
||||
const val SERVER_GUID = "server_guid"
|
||||
const val RECEIPT_TIMESTAMP = "receipt_timestamp"
|
||||
const val EXPORT_STATE = "export_state"
|
||||
@@ -277,6 +278,7 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
|
||||
$VIEW_ONCE INTEGER DEFAULT 0,
|
||||
$REACTIONS_UNREAD INTEGER DEFAULT 0,
|
||||
$REACTIONS_LAST_SEEN INTEGER DEFAULT -1,
|
||||
$REMOTE_DELETED INTEGER DEFAULT 0,
|
||||
$MENTIONS_SELF INTEGER DEFAULT 0,
|
||||
$NOTIFIED_TIMESTAMP INTEGER DEFAULT 0,
|
||||
$SERVER_GUID TEXT DEFAULT NULL,
|
||||
|
||||
@@ -160,7 +160,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V303_CaseInsensitiv
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V304_CallAndReplyNotificationSettings
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V305_AddStoryArchivedColumn
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V306_AddRemoteDeletedColumn
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V307_RemoveRemoteDeletedColumn
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V308_AddBackRemoteDeletedColumn
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase as SignalSqliteDatabase
|
||||
|
||||
/**
|
||||
@@ -328,10 +328,11 @@ object SignalDatabaseMigrations {
|
||||
304 to V304_CallAndReplyNotificationSettings,
|
||||
305 to V305_AddStoryArchivedColumn,
|
||||
306 to V306_AddRemoteDeletedColumn,
|
||||
307 to V307_RemoveRemoteDeletedColumn
|
||||
// 307 to V307_RemoveRemoteDeletedColumn - Removed due to unsolvable OOM crashes. [TODO]: Attempt to fix in the future
|
||||
308 to V308_AddBackRemoteDeletedColumn
|
||||
)
|
||||
|
||||
const val DATABASE_VERSION = 307
|
||||
const val DATABASE_VERSION = 308
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SignalSqliteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* Attempts to remove the remote_deleted column again but in its own isolated change
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V307_RemoveRemoteDeletedColumn : SignalDatabaseMigration {
|
||||
|
||||
private val TAG = Log.tag(V307_RemoveRemoteDeletedColumn::class.java)
|
||||
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
val start = System.currentTimeMillis()
|
||||
if (!SqlUtil.columnExists(db, "message", "remote_deleted")) {
|
||||
Log.i(TAG, "Does not have remote_deleted column!")
|
||||
return
|
||||
}
|
||||
|
||||
db.execSQL("ALTER TABLE message DROP COLUMN remote_deleted")
|
||||
Log.i(TAG, "Dropping remote_deleted column, took ${System.currentTimeMillis() - start}ms")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* Because of an OOM in [V302_AddDeletedByColumn] and V307, we could not drop the remote_deleted column for everyone.
|
||||
* This adds it back for the people who dropped it.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V308_AddBackRemoteDeletedColumn : SignalDatabaseMigration {
|
||||
|
||||
private val TAG = Log.tag(V308_AddBackRemoteDeletedColumn::class.java)
|
||||
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
if (SqlUtil.columnExists(db, "message", "remote_deleted")) {
|
||||
Log.i(TAG, "Already have remote deleted column!")
|
||||
return
|
||||
}
|
||||
|
||||
db.execSQL("ALTER TABLE message ADD COLUMN remote_deleted INTEGER DEFAULT 0")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user