2023-03-14 00:44:02 +01:00
|
|
|
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import GRDB
|
|
|
|
import SessionUtilitiesKit
|
|
|
|
|
2023-03-14 03:07:36 +01:00
|
|
|
/// This migration adds the FTS table back for internal test users whose FTS table was removed unintentionally
|
2023-03-14 00:44:02 +01:00
|
|
|
enum _012_AddFTSIfNeeded: Migration {
|
|
|
|
static let target: TargetMigrations.Identifier = .messagingKit
|
2023-09-25 10:32:56 +02:00
|
|
|
static let identifier: String = "AddFTSIfNeeded" // stringlint:disable
|
2023-03-14 00:44:02 +01:00
|
|
|
static let needsConfigSync: Bool = false
|
2023-08-11 10:02:06 +02:00
|
|
|
static let minExpectedRunDuration: TimeInterval = 0.01
|
2023-03-14 00:44:02 +01:00
|
|
|
|
|
|
|
static func migrate(_ db: Database) throws {
|
|
|
|
// Fix an issue that the fullTextSearchTable was dropped unintentionally and global search won't work.
|
|
|
|
// This issue only happens to internal test users.
|
|
|
|
if try db.tableExists(Interaction.fullTextSearchTableName) == false {
|
|
|
|
try db.create(virtualTable: Interaction.fullTextSearchTableName, using: FTS5()) { t in
|
|
|
|
t.synchronize(withTable: Interaction.databaseTableName)
|
|
|
|
t.tokenizer = _001_InitialSetupMigration.fullTextSearchTokenizer
|
|
|
|
|
|
|
|
t.column(Interaction.Columns.body.name)
|
|
|
|
t.column(Interaction.Columns.threadId.name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Storage.update(progress: 1, for: self, in: target) // In case this is the last migration
|
|
|
|
}
|
|
|
|
}
|