Prune old record types

This commit is contained in:
Max Radermacher 2026-06-01 12:49:00 -05:00 committed by GitHub
parent aa7bced824
commit 7dded9229a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 53 additions and 150 deletions

View File

@ -1,72 +1,27 @@
{ {
"#comment": "NOTE: This file is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run `sds_codegen.sh`.", "#comment": "NOTE: This file is generated by /Scripts/sds_codegen/sds_generate.py. Do not manually edit it, instead run `sds_codegen.sh`.",
"BaseModel": 56, "#max": 80,
"ExperienceUpgrade": 55,
"IncomingGroupsV2MessageJob": 63,
"InstalledSticker": 24,
"OWS100RemoveTSRecipientsMigration": 40,
"OWS101ExistingUsersBlockOnIdentityChange": 43,
"OWS102MoveLoggingPreferenceToUserDefaults": 47,
"OWS103EnableVideoCalling": 42,
"OWS104CreateRecipientIdentities": 45,
"OWS105AttachmentFilePaths": 44,
"OWS107LegacySounds": 50,
"OWS108CallLoggingPreference": 48,
"OWS109OutgoingMessageState": 51,
"OWSAddToContactsOfferMessage": 25, "OWSAddToContactsOfferMessage": 25,
"OWSAddToProfileWhitelistOfferMessage": 7, "OWSAddToProfileWhitelistOfferMessage": 7,
"OWSBackupFragment": 32,
"OWSContactOffersInteraction": 22,
"OWSContactQuery": 57,
"OWSDatabaseMigration": 46,
"OWSDevice": 33,
"OWSDisappearingConfigurationUpdateInfoMessage": 28, "OWSDisappearingConfigurationUpdateInfoMessage": 28,
"OWSDisappearingMessagesConfiguration": 39,
"OWSGroupCallMessage": 65, "OWSGroupCallMessage": 65,
"OWSIncomingArchivedPaymentMessage": 78, "OWSIncomingArchivedPaymentMessage": 78,
"OWSIncomingContactSyncJobRecord": 61,
"OWSIncomingGroupSyncJobRecord": 60,
"OWSIncomingPaymentMessage": 75, "OWSIncomingPaymentMessage": 75,
"OWSLinkedDeviceReadReceipt": 36,
"OWSLocalUserLeaveGroupJobRecord": 74,
"OWSMessageContentJob": 15,
"OWSOutgoingArchivedPaymentMessage": 79, "OWSOutgoingArchivedPaymentMessage": 79,
"OWSOutgoingPaymentMessage": 68, "OWSOutgoingPaymentMessage": 68,
"OWSPaymentActivationRequestFinishedMessage": 77,
"OWSPaymentActivationRequestMessage": 76,
"OWSReaction": 62,
"OWSReceiptCredentialRedemptionJobRecord": 71,
"OWSRecipientIdentity": 38,
"OWSRecoverableDecryptionPlaceholder": 70, "OWSRecoverableDecryptionPlaceholder": 70,
"OWSResaveCollectionDBMigration": 49,
"OWSSendGiftBadgeJobRecord": 73,
"OWSSessionResetJobRecord": 52,
"OWSUnknownContactBlockOfferMessage": 5, "OWSUnknownContactBlockOfferMessage": 5,
"OWSUnknownDBObject": 37,
"OWSUnknownProtocolVersionMessage": 54, "OWSUnknownProtocolVersionMessage": 54,
"OWSUserProfile": 41,
"OWSVerificationStateChangeMessage": 13, "OWSVerificationStateChangeMessage": 13,
"SSKJobRecord": 34,
"SSKMessageDecryptJobRecord": 53,
"SSKMessageSenderJobRecord": 35,
"SignalAccount": 30,
"SignalRecipient": 31,
"StickerPack": 14,
"TSCall": 20, "TSCall": 20,
"TSErrorMessage": 9, "TSErrorMessage": 9,
"TSGroupMember": 69,
"TSIncomingMessage": 19, "TSIncomingMessage": 19,
"TSInfoMessage": 10, "TSInfoMessage": 10,
"TSInteraction": 16, "TSInteraction": 16,
"TSInvalidIdentityKeyErrorMessage": 17, "TSInvalidIdentityKeyErrorMessage": 17,
"TSInvalidIdentityKeyReceivingErrorMessage": 1, "TSInvalidIdentityKeyReceivingErrorMessage": 1,
"TSInvalidIdentityKeySendingErrorMessage": 23, "TSInvalidIdentityKeySendingErrorMessage": 23,
"TSMention": 64,
"TSMessage": 11, "TSMessage": 11,
"TSOutgoingMessage": 21, "TSOutgoingMessage": 21,
"TSPaymentModel": 67, "TSUnreadIndicatorInteraction": 4
"TSPaymentRequestModel": 66,
"TSRecipientReadReceipt": 12,
"TSUnreadIndicatorInteraction": 4,
"TestModel": 59
} }

View File

@ -2440,31 +2440,23 @@ record_type_map = {}
# It's critical that our "record type" values are consistent, even if we add/remove/rename model classes. # It's critical that our "record type" values are consistent, even if we add/remove/rename model classes.
# Therefore we persist the mapping of known classes in a JSON file that is under source control. # Therefore we persist the mapping of known classes in a JSON file that is under source control.
def update_record_type_map(record_type_swift_path, record_type_json_path): def update_record_type_map(record_type_swift_path, record_type_json_path):
record_type_map_filepath = record_type_json_path old_record_types = {}
if os.path.exists(record_type_json_path):
with open(record_type_json_path, "r") as f:
old_record_types = json.load(f)
if os.path.exists(record_type_map_filepath): max_record_type = old_record_types.get("#max", 0)
with open(record_type_map_filepath, "rt") as f:
json_string = f.read()
json_data = json.loads(json_string)
record_type_map.update(json_data)
max_record_type = 0
for class_name in record_type_map:
if class_name.startswith("#"):
continue
record_type = record_type_map[class_name]
max_record_type = max(max_record_type, record_type)
for clazz in global_class_map.values(): for clazz in global_class_map.values():
if clazz.name not in record_type_map: if not clazz.should_generate_extensions():
continue
if not clazz.should_generate_extensions(): if clazz.name in old_record_types:
continue record_type_map[clazz.name] = old_record_types[clazz.name]
else:
max_record_type = int(max_record_type) + 1 max_record_type += 1
record_type = max_record_type record_type_map[clazz.name] = max_record_type
record_type_map[clazz.name] = record_type
record_type_map["#max"] = max_record_type
record_type_map["#comment"] = ( record_type_map["#comment"] = (
"NOTE: This file is generated by %s. Do not manually edit it, instead run `sds_codegen.sh`." "NOTE: This file is generated by %s. Do not manually edit it, instead run `sds_codegen.sh`."
% (sds_common.pretty_module_path(__file__),) % (sds_common.pretty_module_path(__file__),)
@ -2472,7 +2464,7 @@ def update_record_type_map(record_type_swift_path, record_type_json_path):
json_string = json.dumps(record_type_map, sort_keys=True, indent=4) json_string = json.dumps(record_type_map, sort_keys=True, indent=4)
sds_common.write_text_file_if_changed(record_type_map_filepath, json_string) sds_common.write_text_file_if_changed(record_type_json_path, json_string)
# TODO: We'll need to import SignalServiceKit for non-SSK classes. # TODO: We'll need to import SignalServiceKit for non-SSK classes.

View File

@ -55,7 +55,7 @@ public enum VerificationState: Equatable {
/// Record for a recipient's identity key and associated fields used to make trust decisions. /// Record for a recipient's identity key and associated fields used to make trust decisions.
public final class OWSRecipientIdentity: NSObject, SDSCodableModel, Decodable { public final class OWSRecipientIdentity: NSObject, SDSCodableModel, Decodable {
public static let databaseTableName = "model_OWSRecipientIdentity" public static let databaseTableName = "model_OWSRecipientIdentity"
private static var recordType: SDSRecordType { .recipientIdentity } private static let recordType: UInt = 38
public var id: Int64? public var id: Int64?
public let uniqueId: String public let uniqueId: String
@ -94,7 +94,7 @@ public final class OWSRecipientIdentity: NSObject, SDSCodableModel, Decodable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
guard decodedRecordType == Self.recordType.rawValue else { guard decodedRecordType == Self.recordType else {
owsFailDebug("Unexpected record type: \(decodedRecordType)") owsFailDebug("Unexpected record type: \(decodedRecordType)")
throw SDSError.invalidValue() throw SDSError.invalidValue()
} }
@ -110,7 +110,7 @@ public final class OWSRecipientIdentity: NSObject, SDSCodableModel, Decodable {
public func encode(to encoder: any Encoder) throws { public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.id, forKey: .id) try container.encodeIfPresent(self.id, forKey: .id)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(self.uniqueId, forKey: .uniqueId) try container.encode(self.uniqueId, forKey: .uniqueId)
try container.encode(self.uniqueId, forKey: .accountId) try container.encode(self.uniqueId, forKey: .accountId)
try container.encode(self.identityKey, forKey: .identityKey) try container.encode(self.identityKey, forKey: .identityKey)

View File

@ -105,7 +105,7 @@ public struct DisappearingMessagesConfigurationRecord: FetchableRecord, MutableP
public func encode(to encoder: any Encoder) throws { public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.id, forKey: .id) try container.encodeIfPresent(self.id, forKey: .id)
try container.encode(SDSRecordType.disappearingMessagesConfiguration.rawValue, forKey: .recordType) try container.encode(39, forKey: .recordType)
try container.encode(self.threadUniqueId, forKey: .threadUniqueId) try container.encode(self.threadUniqueId, forKey: .threadUniqueId)
try container.encode(self.durationSeconds, forKey: .durationSeconds) try container.encode(self.durationSeconds, forKey: .durationSeconds)
try container.encode(self.isEnabled, forKey: .isEnabled) try container.encode(self.isEnabled, forKey: .isEnabled)

View File

@ -9,7 +9,7 @@ public import LibSignalClient
@objc(SignalAccount) @objc(SignalAccount)
public final class SignalAccount: NSObject, SDSCodableModel, Decodable { public final class SignalAccount: NSObject, SDSCodableModel, Decodable {
public static let databaseTableName = "model_SignalAccount" public static let databaseTableName = "model_SignalAccount"
private static var recordType: SDSRecordType { .signalAccount } private static let recordType: UInt = 30
public enum CodingKeys: String, CodingKey, ColumnExpression { public enum CodingKeys: String, CodingKey, ColumnExpression {
case id case id
@ -105,7 +105,7 @@ public final class SignalAccount: NSObject, SDSCodableModel, Decodable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
owsAssertDebug(decodedRecordType == Self.recordType.rawValue, "Unexpectedly decoded record with wrong type!") owsAssertDebug(decodedRecordType == Self.recordType, "Unexpectedly decoded record with wrong type!")
id = try container.decodeIfPresent(RowId.self, forKey: .id) id = try container.decodeIfPresent(RowId.self, forKey: .id)
uniqueId = try container.decode(String.self, forKey: .uniqueId) uniqueId = try container.decode(String.self, forKey: .uniqueId)
@ -140,7 +140,7 @@ public final class SignalAccount: NSObject, SDSCodableModel, Decodable {
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try id.map { try container.encode($0, forKey: .id) } try id.map { try container.encode($0, forKey: .id) }
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)

View File

@ -19,6 +19,7 @@ public import LibSignalClient
/// doesn't have any devices, then that user isn't registered. /// doesn't have any devices, then that user isn't registered.
public struct SignalRecipient: FetchableRecord, PersistableRecord, Codable { public struct SignalRecipient: FetchableRecord, PersistableRecord, Codable {
public static let databaseTableName = "model_SignalRecipient" public static let databaseTableName = "model_SignalRecipient"
private static let recordType: UInt = 31
public enum Constants { public enum Constants {
public static let distantPastUnregisteredTimestamp: UInt64 = 1 public static let distantPastUnregisteredTimestamp: UInt64 = 1
@ -109,7 +110,7 @@ public struct SignalRecipient: FetchableRecord, PersistableRecord, Codable {
) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING * ) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING *
""", """,
arguments: [ arguments: [
SDSRecordType.signalRecipient.rawValue, Self.recordType,
UUID().uuidString, UUID().uuidString,
aci?.serviceIdUppercaseString, aci?.serviceIdUppercaseString,
phoneNumber?.stringValue, phoneNumber?.stringValue,
@ -141,7 +142,7 @@ public struct SignalRecipient: FetchableRecord, PersistableRecord, Codable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(UInt.self, forKey: .recordType) let decodedRecordType = try container.decode(UInt.self, forKey: .recordType)
guard decodedRecordType == SDSRecordType.signalRecipient.rawValue else { guard decodedRecordType == Self.recordType else {
owsFailDebug("Unexpected record type: \(decodedRecordType)") owsFailDebug("Unexpected record type: \(decodedRecordType)")
throw SDSError.invalidValue() throw SDSError.invalidValue()
} }
@ -167,7 +168,7 @@ public struct SignalRecipient: FetchableRecord, PersistableRecord, Codable {
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id) try container.encode(id, forKey: .id)
try container.encode(SDSRecordType.signalRecipient.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)
try container.encodeIfPresent(aciString, forKey: .aciString) try container.encodeIfPresent(aciString, forKey: .aciString)
try container.encodeIfPresent(pni?.serviceIdUppercaseString, forKey: .pni) try container.encodeIfPresent(pni?.serviceIdUppercaseString, forKey: .pni)

View File

@ -29,7 +29,7 @@ public import LibSignalClient
/// ACI). Take care if this model is ever extended to include invited members. /// ACI). Take care if this model is ever extended to include invited members.
public final class TSGroupMember: NSObject, SDSCodableModel, Decodable { public final class TSGroupMember: NSObject, SDSCodableModel, Decodable {
public static let databaseTableName = "model_TSGroupMember" public static let databaseTableName = "model_TSGroupMember"
private static var recordType: SDSRecordType { .groupMember } private static let recordType: UInt = 69
public enum CodingKeys: String, CodingKey, ColumnExpression { public enum CodingKeys: String, CodingKey, ColumnExpression {
case id case id
@ -66,7 +66,7 @@ public final class TSGroupMember: NSObject, SDSCodableModel, Decodable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
owsAssertDebug(decodedRecordType == Self.recordType.rawValue, "Unexpectedly decoded record with wrong type.") owsAssertDebug(decodedRecordType == Self.recordType, "Unexpectedly decoded record with wrong type.")
id = try container.decodeIfPresent(RowId.self, forKey: .id) id = try container.decodeIfPresent(RowId.self, forKey: .id)
uniqueId = try container.decode(String.self, forKey: .uniqueId) uniqueId = try container.decode(String.self, forKey: .uniqueId)
@ -80,7 +80,7 @@ public final class TSGroupMember: NSObject, SDSCodableModel, Decodable {
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(id, forKey: .id) try container.encodeIfPresent(id, forKey: .id)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)
try container.encode(groupThreadId, forKey: .groupThreadId) try container.encode(groupThreadId, forKey: .groupThreadId)
try container.encodeIfPresent(serviceId?.serviceIdUppercaseString, forKey: .serviceId) try container.encodeIfPresent(serviceId?.serviceIdUppercaseString, forKey: .serviceId)

View File

@ -208,7 +208,7 @@ struct DonationReceiptCredentialRedemptionJobFinder {
) )
""" """
let arguments: StatementArguments = [ let arguments: StatementArguments = [
SDSRecordType.receiptCredentialRedemptionJobRecord.rawValue, JobRecord.JobRecordType.donationReceiptCredentialRedemption.rawValue,
subscriberID, subscriberID,
] ]

View File

@ -109,7 +109,7 @@ private func jobExists(threadId: String, transaction: DBReadTransaction) -> Bool
""" """
let arguments: StatementArguments = [ let arguments: StatementArguments = [
threadId, threadId,
SDSRecordType.sendGiftBadgeJobRecord.rawValue, JobRecord.JobRecordType.sendGiftBadge.rawValue,
SendGiftBadgeJobRecord.Status.permanentlyFailed.rawValue, SendGiftBadgeJobRecord.Status.permanentlyFailed.rawValue,
SendGiftBadgeJobRecord.Status.obsolete.rawValue, SendGiftBadgeJobRecord.Status.obsolete.rawValue,
] ]

View File

@ -10,7 +10,7 @@ public class ExperienceUpgrade: Codable, FetchableRecord, PersistableRecord {
public typealias IDType = Int64 public typealias IDType = Int64
public static let databaseTableName = "model_ExperienceUpgrade" public static let databaseTableName = "model_ExperienceUpgrade"
private static var recordType: SDSRecordType { .experienceUpgrade } private static let recordType: UInt = 55
public enum CodingKeys: String, CodingKey, ColumnExpression { public enum CodingKeys: String, CodingKey, ColumnExpression {
case id case id
@ -79,7 +79,7 @@ public class ExperienceUpgrade: Codable, FetchableRecord, PersistableRecord {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
owsAssertDebug(decodedRecordType == Self.recordType.rawValue, "Unexpectedly decoded record with wrong type.") owsAssertDebug(decodedRecordType == Self.recordType, "Unexpectedly decoded record with wrong type.")
id = try container.decodeIfPresent(IDType.self, forKey: .id) id = try container.decodeIfPresent(IDType.self, forKey: .id)
@ -105,7 +105,7 @@ public class ExperienceUpgrade: Codable, FetchableRecord, PersistableRecord {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try id.map { try container.encode($0, forKey: .id) } try id.map { try container.encode($0, forKey: .id) }
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)
try container.encode(firstViewedTimestamp, forKey: .firstViewedTimestamp) try container.encode(firstViewedTimestamp, forKey: .firstViewedTimestamp)

View File

@ -8,6 +8,7 @@ import GRDB
struct GroupMessageProcessorJob: Codable, PersistableRecord, FetchableRecord { struct GroupMessageProcessorJob: Codable, PersistableRecord, FetchableRecord {
static let databaseTableName: String = "model_IncomingGroupsV2MessageJob" static let databaseTableName: String = "model_IncomingGroupsV2MessageJob"
private static let recordType: UInt = 63
let id: Int64 let id: Int64
let groupId: Data? let groupId: Data?
@ -88,7 +89,7 @@ struct GroupMessageProcessorJob: Codable, PersistableRecord, FetchableRecord {
wasReceivedByUD, wasReceivedByUD,
Int64(bitPattern: serverDeliveryTimestamp), Int64(bitPattern: serverDeliveryTimestamp),
Date().timeIntervalSince1970, Date().timeIntervalSince1970,
SDSRecordType.incomingGroupsV2MessageJob.rawValue, Self.recordType,
UUID().uuidString, UUID().uuidString,
], ],
)! )!

View File

@ -10,7 +10,7 @@ public import LibSignalClient
@objc @objc
public final class TSMention: NSObject, SDSCodableModel, Decodable { public final class TSMention: NSObject, SDSCodableModel, Decodable {
public static let databaseTableName = "model_TSMention" public static let databaseTableName = "model_TSMention"
private static var recordType: SDSRecordType { .mention } private static let recordType: UInt = 64
public enum CodingKeys: String, CodingKey, ColumnExpression { public enum CodingKeys: String, CodingKey, ColumnExpression {
case id case id
@ -47,7 +47,7 @@ public final class TSMention: NSObject, SDSCodableModel, Decodable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
owsAssertDebug(decodedRecordType == Self.recordType.rawValue, "Unexpectedly decoded record with wrong type.") owsAssertDebug(decodedRecordType == Self.recordType, "Unexpectedly decoded record with wrong type.")
id = try container.decodeIfPresent(RowId.self, forKey: .id) id = try container.decodeIfPresent(RowId.self, forKey: .id)
uniqueId = try container.decode(String.self, forKey: .uniqueId) uniqueId = try container.decode(String.self, forKey: .uniqueId)
@ -62,7 +62,7 @@ public final class TSMention: NSObject, SDSCodableModel, Decodable {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try id.map { try container.encode($0, forKey: .id) } try id.map { try container.encode($0, forKey: .id) }
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)
try container.encode(uniqueMessageId, forKey: .uniqueMessageId) try container.encode(uniqueMessageId, forKey: .uniqueMessageId)

View File

@ -10,7 +10,7 @@ public import LibSignalClient
@objc(OWSReaction) // Named explicitly to preserve NSKeyedUnarchiving compatability @objc(OWSReaction) // Named explicitly to preserve NSKeyedUnarchiving compatability
public final class OWSReaction: NSObject, SDSCodableModel, Decodable, NSSecureCoding { public final class OWSReaction: NSObject, SDSCodableModel, Decodable, NSSecureCoding {
public static let databaseTableName = "model_OWSReaction" public static let databaseTableName = "model_OWSReaction"
private static var recordType: SDSRecordType { .reaction } private static let recordType: UInt = 62
public enum CodingKeys: String, CodingKey, ColumnExpression { public enum CodingKeys: String, CodingKey, ColumnExpression {
case id case id
@ -86,7 +86,7 @@ public final class OWSReaction: NSObject, SDSCodableModel, Decodable, NSSecureCo
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
owsAssertDebug(decodedRecordType == Self.recordType.rawValue, "Unexpectedly decoded record with wrong type.") owsAssertDebug(decodedRecordType == Self.recordType, "Unexpectedly decoded record with wrong type.")
id = try container.decodeIfPresent(RowId.self, forKey: .id) id = try container.decodeIfPresent(RowId.self, forKey: .id)
uniqueId = try container.decode(String.self, forKey: .uniqueId) uniqueId = try container.decode(String.self, forKey: .uniqueId)
@ -107,7 +107,7 @@ public final class OWSReaction: NSObject, SDSCodableModel, Decodable, NSSecureCo
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try id.map { try container.encode($0, forKey: .id) } try id.map { try container.encode($0, forKey: .id) }
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)
try container.encode(uniqueMessageId, forKey: .uniqueMessageId) try container.encode(uniqueMessageId, forKey: .uniqueMessageId)

View File

@ -8,7 +8,7 @@ public import GRDB
public final class InstalledStickerRecord: SDSCodableModel, Decodable { public final class InstalledStickerRecord: SDSCodableModel, Decodable {
public static let databaseTableName: String = "model_InstalledSticker" public static let databaseTableName: String = "model_InstalledSticker"
private static let recordType: SDSRecordType = .installedSticker private static let recordType: UInt = 24
public var id: Int64? public var id: Int64?
public let uniqueId: String public let uniqueId: String
@ -39,7 +39,7 @@ public final class InstalledStickerRecord: SDSCodableModel, Decodable {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.id, forKey: .id) try container.encodeIfPresent(self.id, forKey: .id)
try container.encode(self.uniqueId, forKey: .uniqueId) try container.encode(self.uniqueId, forKey: .uniqueId)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(LegacySDSSerializer().serializeAsLegacySDSData(self.info), forKey: .info) try container.encode(LegacySDSSerializer().serializeAsLegacySDSData(self.info), forKey: .info)
try container.encodeIfPresent(self.emojiString, forKey: .emojiString) try container.encodeIfPresent(self.emojiString, forKey: .emojiString)
try container.encodeIfPresent(self.contentType, forKey: .contentType) try container.encodeIfPresent(self.contentType, forKey: .contentType)

View File

@ -8,7 +8,7 @@ public import GRDB
public final class StickerPackRecord: SDSCodableModel, Decodable, Equatable, NSCopying { public final class StickerPackRecord: SDSCodableModel, Decodable, Equatable, NSCopying {
public static let databaseTableName: String = "model_StickerPack" public static let databaseTableName: String = "model_StickerPack"
private static let recordType: SDSRecordType = .stickerPack private static let recordType: UInt = 14
public var id: Int64? public var id: Int64?
public let uniqueId: String public let uniqueId: String
@ -53,7 +53,7 @@ public final class StickerPackRecord: SDSCodableModel, Decodable, Equatable, NSC
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.id, forKey: .id) try container.encodeIfPresent(self.id, forKey: .id)
try container.encode(self.uniqueId, forKey: .uniqueId) try container.encode(self.uniqueId, forKey: .uniqueId)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(LegacySDSSerializer().serializeAsLegacySDSData(self.info), forKey: .info) try container.encode(LegacySDSSerializer().serializeAsLegacySDSData(self.info), forKey: .info)
try container.encodeIfPresent(self.title, forKey: .title) try container.encodeIfPresent(self.title, forKey: .title)
try container.encodeIfPresent(self.author, forKey: .author) try container.encodeIfPresent(self.author, forKey: .author)

View File

@ -15,7 +15,7 @@ public import LibSignalClient
// all payments. // all payments.
public final class TSPaymentModel: NSObject, SDSCodableModel, Decodable { public final class TSPaymentModel: NSObject, SDSCodableModel, Decodable {
public static let databaseTableName: String = "model_TSPaymentModel" public static let databaseTableName: String = "model_TSPaymentModel"
private static let recordType: SDSRecordType = .paymentModel private static let recordType: UInt = 67
public var id: Int64? public var id: Int64?
public let uniqueId: String public let uniqueId: String
@ -119,7 +119,7 @@ public final class TSPaymentModel: NSObject, SDSCodableModel, Decodable {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.id, forKey: .id) try container.encode(self.id, forKey: .id)
try container.encode(self.uniqueId, forKey: .uniqueId) try container.encode(self.uniqueId, forKey: .uniqueId)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(self.paymentType, forKey: .paymentType) try container.encode(self.paymentType, forKey: .paymentType)
try container.encode(self.paymentState, forKey: .paymentState) try container.encode(self.paymentState, forKey: .paymentState)
try container.encode(self.paymentFailure, forKey: .paymentFailure) try container.encode(self.paymentFailure, forKey: .paymentFailure)

View File

@ -139,7 +139,7 @@ public final class UserProfileNotifications: NSObject {
@objc @objc
public final class OWSUserProfile: NSObject, SDSCodableModel, Decodable { public final class OWSUserProfile: NSObject, SDSCodableModel, Decodable {
public static let databaseTableName = "model_OWSUserProfile" public static let databaseTableName = "model_OWSUserProfile"
private static var recordType: SDSRecordType { .userProfile } private static let recordType: UInt = 41
/// An address used to identify an ``OWSUserProfile``. /// An address used to identify an ``OWSUserProfile``.
public enum Address: Hashable { public enum Address: Hashable {
@ -393,7 +393,7 @@ public final class OWSUserProfile: NSObject, SDSCodableModel, Decodable {
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(id, forKey: .id) try container.encodeIfPresent(id, forKey: .id)
try container.encode(Self.recordType.rawValue, forKey: .recordType) try container.encode(Self.recordType, forKey: .recordType)
try container.encode(uniqueId, forKey: .uniqueId) try container.encode(uniqueId, forKey: .uniqueId)
try container.encodeIfPresent(serviceIdString, forKey: .serviceIdString) try container.encodeIfPresent(serviceIdString, forKey: .serviceIdString)
try container.encodeIfPresent(phoneNumber, forKey: .phoneNumber) try container.encodeIfPresent(phoneNumber, forKey: .phoneNumber)
@ -417,7 +417,7 @@ public final class OWSUserProfile: NSObject, SDSCodableModel, Decodable {
let container = try decoder.container(keyedBy: CodingKeys.self) let container = try decoder.container(keyedBy: CodingKeys.self)
let decodedRecordType = try container.decode(Int64.self, forKey: .recordType) let decodedRecordType = try container.decode(Int64.self, forKey: .recordType)
guard decodedRecordType == Self.recordType.rawValue else { guard decodedRecordType == Self.recordType else {
owsFailDebug("Unexpected record type: \(decodedRecordType)") owsFailDebug("Unexpected record type: \(decodedRecordType)")
throw SDSError.invalidValue() throw SDSError.invalidValue()
} }

View File

@ -1757,7 +1757,7 @@ public class GRDBSchemaMigrator {
try transaction.database.execute(sql: "UPDATE model_TSInteraction SET serverDeliveryTimestamp = 0 WHERE recordType IS \(SDSRecordType.incomingMessage.rawValue)") try transaction.database.execute(sql: "UPDATE model_TSInteraction SET serverDeliveryTimestamp = 0 WHERE recordType IS \(SDSRecordType.incomingMessage.rawValue)")
// Backfill all jobs with "0" as their timestamp // Backfill all jobs with "0" as their timestamp
try transaction.database.execute(sql: "UPDATE model_SSKJobRecord SET serverDeliveryTimestamp = 0 WHERE recordType IS \(SDSRecordType.messageDecryptJobRecord.rawValue)") try transaction.database.execute(sql: "UPDATE model_SSKJobRecord SET serverDeliveryTimestamp = 0 WHERE recordType IS 53")
return .success(()) return .success(())
} }

View File

@ -18,66 +18,20 @@ public enum SDSRecordType: UInt, CaseIterable {
case errorMessage = 9 case errorMessage = 9
case infoMessage = 10 case infoMessage = 10
case message = 11 case message = 11
case recipientReadReceipt = 12
case verificationStateChangeMessage = 13 case verificationStateChangeMessage = 13
case stickerPack = 14
case messageContentJob = 15
case interaction = 16 case interaction = 16
case invalidIdentityKeyErrorMessage = 17 case invalidIdentityKeyErrorMessage = 17
case incomingMessage = 19 case incomingMessage = 19
case call = 20 case call = 20
case outgoingMessage = 21 case outgoingMessage = 21
case contactOffersInteraction = 22
case invalidIdentityKeySendingErrorMessage = 23 case invalidIdentityKeySendingErrorMessage = 23
case installedSticker = 24
case addToContactsOfferMessage = 25 case addToContactsOfferMessage = 25
case disappearingConfigurationUpdateInfoMessage = 28 case disappearingConfigurationUpdateInfoMessage = 28
case signalAccount = 30
case signalRecipient = 31
case backupFragment = 32
case device = 33
case jobRecord = 34
case messageSenderJobRecord = 35
case linkedDeviceReadReceipt = 36
case unknownDBObject = 37
case recipientIdentity = 38
case disappearingMessagesConfiguration = 39
case _100RemoveTSRecipientsMigration = 40
case userProfile = 41
case _103EnableVideoCalling = 42
case _101ExistingUsersBlockOnIdentityChange = 43
case _105AttachmentFilePaths = 44
case _104CreateRecipientIdentities = 45
case databaseMigration = 46
case _102MoveLoggingPreferenceToUserDefaults = 47
case _108CallLoggingPreference = 48
case resaveCollectionDBMigration = 49
case _107LegacySounds = 50
case _109OutgoingMessageState = 51
case sessionResetJobRecord = 52
case messageDecryptJobRecord = 53
case unknownProtocolVersionMessage = 54 case unknownProtocolVersionMessage = 54
case experienceUpgrade = 55
case baseModel = 56
case contactQuery = 57
case testModel = 59
case incomingGroupSyncJobRecord = 60
case incomingContactSyncJobRecord = 61
case reaction = 62
case incomingGroupsV2MessageJob = 63
case mention = 64
case groupCallMessage = 65 case groupCallMessage = 65
case paymentRequestModel = 66
case paymentModel = 67
case outgoingPaymentMessage = 68 case outgoingPaymentMessage = 68
case groupMember = 69
case recoverableDecryptionPlaceholder = 70 case recoverableDecryptionPlaceholder = 70
case receiptCredentialRedemptionJobRecord = 71
case sendGiftBadgeJobRecord = 73
case localUserLeaveGroupJobRecord = 74
case incomingPaymentMessage = 75 case incomingPaymentMessage = 75
case paymentActivationRequestMessage = 76
case paymentActivationRequestFinishedMessage = 77
case incomingArchivedPaymentMessage = 78 case incomingArchivedPaymentMessage = 78
case outgoingArchivedPaymentMessage = 79 case outgoingArchivedPaymentMessage = 79
} }