mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-18 15:56:24 +01:00
Remove remote_deleted column.
This commit is contained in:
committed by
jeffrey-signal
parent
374347da04
commit
1a70449c4c
@@ -190,7 +190,6 @@ 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"
|
||||
const val SERVER_GUID = "server_guid"
|
||||
const val RECEIPT_TIMESTAMP = "receipt_timestamp"
|
||||
const val EXPORT_STATE = "export_state"
|
||||
@@ -278,7 +277,6 @@ 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,
|
||||
|
||||
@@ -159,6 +159,8 @@ import org.thoughtcrime.securesms.database.helpers.migration.V302_AddDeletedByCo
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V303_CaseInsensitiveUsernames
|
||||
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.SQLiteDatabase as SignalSqliteDatabase
|
||||
|
||||
/**
|
||||
@@ -324,10 +326,12 @@ object SignalDatabaseMigrations {
|
||||
302 to V302_AddDeletedByColumn,
|
||||
303 to V303_CaseInsensitiveUsernames,
|
||||
304 to V304_CallAndReplyNotificationSettings,
|
||||
305 to V305_AddStoryArchivedColumn
|
||||
305 to V305_AddStoryArchivedColumn,
|
||||
306 to V306_AddRemoteDeletedColumn,
|
||||
307 to V307_RemoveRemoteDeletedColumn
|
||||
)
|
||||
|
||||
const val DATABASE_VERSION = 305
|
||||
const val DATABASE_VERSION = 307
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SignalSqliteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
||||
@@ -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], we could not drop the remote_deleted column for everyone.
|
||||
* This adds it back for the people who dropped it.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V306_AddRemoteDeletedColumn : SignalDatabaseMigration {
|
||||
|
||||
private val TAG = Log.tag(V306_AddRemoteDeletedColumn::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")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user