add v4_attachment migration: sectionPath on attachment, hasAttachments on message
This commit is contained in:
@@ -186,6 +186,15 @@ public enum DatabaseSetup {
|
||||
try db.create(index: "idx_deferral_deferUntil", on: "deferral", columns: ["deferUntil"])
|
||||
}
|
||||
|
||||
migrator.registerMigration("v4_attachment") { db in
|
||||
try db.alter(table: "attachment") { t in
|
||||
t.add(column: "sectionPath", .text)
|
||||
}
|
||||
try db.alter(table: "message") { t in
|
||||
t.add(column: "hasAttachments", .boolean).notNull().defaults(to: false)
|
||||
}
|
||||
}
|
||||
|
||||
return migrator
|
||||
}
|
||||
|
||||
|
||||
@@ -10,10 +10,11 @@ public struct AttachmentRecord: Codable, FetchableRecord, PersistableRecord, Sen
|
||||
public var size: Int
|
||||
public var contentId: String?
|
||||
public var cachePath: String?
|
||||
public var sectionPath: String?
|
||||
|
||||
public init(
|
||||
id: String, messageId: String, filename: String?, mimeType: String,
|
||||
size: Int, contentId: String?, cachePath: String?
|
||||
size: Int, contentId: String?, cachePath: String?, sectionPath: String? = nil
|
||||
) {
|
||||
self.id = id
|
||||
self.messageId = messageId
|
||||
@@ -22,5 +23,6 @@ public struct AttachmentRecord: Codable, FetchableRecord, PersistableRecord, Sen
|
||||
self.size = size
|
||||
self.contentId = contentId
|
||||
self.cachePath = cachePath
|
||||
self.sectionPath = sectionPath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public struct MessageRecord: Codable, FetchableRecord, PersistableRecord, Sendab
|
||||
public var isRead: Bool
|
||||
public var isFlagged: Bool
|
||||
public var size: Int
|
||||
public var hasAttachments: Bool
|
||||
|
||||
public init(
|
||||
id: String, accountId: String, mailboxId: String, uid: Int,
|
||||
@@ -29,7 +30,7 @@ public struct MessageRecord: Codable, FetchableRecord, PersistableRecord, Sendab
|
||||
subject: String?, fromAddress: String?, fromName: String?,
|
||||
toAddresses: String?, ccAddresses: String?,
|
||||
date: String, snippet: String?, bodyText: String?, bodyHtml: String?,
|
||||
isRead: Bool, isFlagged: Bool, size: Int
|
||||
isRead: Bool, isFlagged: Bool, size: Int, hasAttachments: Bool = false
|
||||
) {
|
||||
self.id = id
|
||||
self.accountId = accountId
|
||||
@@ -50,5 +51,6 @@ public struct MessageRecord: Codable, FetchableRecord, PersistableRecord, Sendab
|
||||
self.isRead = isRead
|
||||
self.isFlagged = isFlagged
|
||||
self.size = size
|
||||
self.hasAttachments = hasAttachments
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user