Schema for pinned messages

This commit is contained in:
kate-signal
2025-11-14 12:47:40 -05:00
committed by GitHub
parent fb019581e6
commit 2606068db4
8 changed files with 114 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "pin-slash.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

View File

@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "pin.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}

Binary file not shown.

View File

@@ -84,6 +84,11 @@ public enum BuildFlags {
public static let serviceIdBinaryOneOf = !serviceIdStrings
public static let serviceIdStrings = TSConstants.isUsingProductionService
public enum PinnedMessages {
public static let send = build <= .dev
public static let receive = build <= .dev
}
}
// MARK: -

View File

@@ -2568,3 +2568,37 @@ CREATE
ON "UsernameLookupRecord"("username" COLLATE NOCASE
)
;
CREATE
TABLE
IF NOT EXISTS "PinnedMessage" (
"id" INTEGER PRIMARY KEY NOT NULL
,"interactionId" INTEGER NOT NULL UNIQUE REFERENCES "model_TSInteraction"("id"
)
ON DELETE
CASCADE
ON UPDATE
CASCADE
,"threadId" INTEGER NOT NULL REFERENCES "model_TSThread"("id"
)
ON DELETE
CASCADE
ON UPDATE
CASCADE
,"expiresAt" INTEGER
)
;
CREATE
INDEX "index_PinnedMessage_on_threadId"
ON "PinnedMessage"("threadId"
)
;
CREATE
INDEX "partial_index_PinnedMessage_on_expiresAt"
ON "PinnedMessage"("expiresAt"
)
WHERE
"expiresAt" IS NOT NULL
;

View File

@@ -309,7 +309,8 @@ public extension DatabaseRecovery {
"BackupOversizeTextCache",
"Poll",
"PollOption",
"PollVote"
"PollVote",
"PinnedMessage"
]
private static func prepareToCopyTablesWithBestEffort(

View File

@@ -335,6 +335,7 @@ public class GRDBSchemaMigrator {
case uniquifyUsernameLookupRecord2
case fixRevokedForRestoredCallLinks
case fixNameForRestoredCallLinks
case addPinnedMessagesTable
// NOTE: Every time we add a migration id, consider
// incrementing grdbSchemaVersionLatest.
@@ -450,7 +451,7 @@ public class GRDBSchemaMigrator {
}
public static let grdbSchemaVersionDefault: UInt = 0
public static let grdbSchemaVersionLatest: UInt = 134
public static let grdbSchemaVersionLatest: UInt = 135
// An optimization for new users, we have the first migration import the latest schema
// and mark any other migrations as "already run".
@@ -4275,6 +4276,47 @@ public class GRDBSchemaMigrator {
return .success(())
}
migrator.registerMigration(.addPinnedMessagesTable) { tx in
try tx.database.create(
table: "PinnedMessage"
) { table in
table.column("id", .integer).primaryKey().notNull()
table.column("interactionId", .integer)
.notNull()
.unique()
.references(
"model_TSInteraction",
column: "id",
onDelete: .cascade,
onUpdate: .cascade
)
table.column("threadId", .integer)
.notNull()
.references(
"model_TSThread",
column: "id",
onDelete: .cascade,
onUpdate: .cascade
)
table.column("expiresAt", .integer)
}
try tx.database.create(
index: "index_PinnedMessage_on_threadId",
on: "PinnedMessage",
columns: ["threadId"]
)
try tx.database.create(
index: "partial_index_PinnedMessage_on_expiresAt",
on: "PinnedMessage",
columns: ["expiresAt"],
condition: Column("expiresAt") != nil
)
return .success(())
}
// MARK: - Schema Migration Insertion Point
}