2022-04-21 08:42:35 +02:00
|
|
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import GRDB
|
|
|
|
import SessionUtilitiesKit
|
|
|
|
import SessionSnodeKit
|
|
|
|
|
|
|
|
/// This migration sets up the standard jobs, since we want these jobs to run before any "once-off" jobs we do this migration
|
|
|
|
/// before running the `YDBToGRDBMigration`
|
|
|
|
enum _002_SetupStandardJobs: Migration {
|
2022-05-31 09:41:02 +02:00
|
|
|
static let target: TargetMigrations.Identifier = .messagingKit
|
2023-09-25 10:32:56 +02:00
|
|
|
static let identifier: String = "SetupStandardJobs" // stringlint:disable
|
2022-05-30 05:04:26 +02:00
|
|
|
static let needsConfigSync: Bool = false
|
2022-05-31 09:41:02 +02:00
|
|
|
static let minExpectedRunDuration: TimeInterval = 0.1
|
2023-10-03 03:52:29 +02:00
|
|
|
static let fetchedTables: [(TableRecord & FetchableRecord).Type] = []
|
|
|
|
static let createdOrAlteredTables: [(TableRecord & FetchableRecord).Type] = []
|
2022-04-21 08:42:35 +02:00
|
|
|
|
|
|
|
static func migrate(_ db: Database) throws {
|
|
|
|
// Start by adding the jobs that don't have collections (in the jobs like these
|
|
|
|
// will be added via migrations)
|
|
|
|
try autoreleasepool {
|
|
|
|
_ = try Job(
|
|
|
|
variant: .disappearingMessages,
|
2022-05-28 09:25:38 +02:00
|
|
|
behaviour: .recurringOnLaunch,
|
2022-07-05 08:47:12 +02:00
|
|
|
shouldBlock: true
|
2022-10-21 08:32:51 +02:00
|
|
|
).migrationSafeInserted(db)
|
2022-04-21 08:42:35 +02:00
|
|
|
|
|
|
|
_ = try Job(
|
2022-05-29 11:26:06 +02:00
|
|
|
variant: .failedMessageSends,
|
2022-05-28 09:25:38 +02:00
|
|
|
behaviour: .recurringOnLaunch,
|
2022-07-05 08:47:12 +02:00
|
|
|
shouldBlock: true
|
2022-10-21 08:32:51 +02:00
|
|
|
).migrationSafeInserted(db)
|
2022-04-21 08:42:35 +02:00
|
|
|
|
|
|
|
_ = try Job(
|
|
|
|
variant: .failedAttachmentDownloads,
|
2022-05-28 09:25:38 +02:00
|
|
|
behaviour: .recurringOnLaunch,
|
2022-07-05 08:47:12 +02:00
|
|
|
shouldBlock: true
|
2022-10-21 08:32:51 +02:00
|
|
|
).migrationSafeInserted(db)
|
2022-04-21 08:42:35 +02:00
|
|
|
|
|
|
|
_ = try Job(
|
2022-04-27 02:48:54 +02:00
|
|
|
variant: .updateProfilePicture,
|
|
|
|
behaviour: .recurringOnActive
|
2022-10-21 08:32:51 +02:00
|
|
|
).migrationSafeInserted(db)
|
2022-04-27 02:48:54 +02:00
|
|
|
|
|
|
|
_ = try Job(
|
|
|
|
variant: .retrieveDefaultOpenGroupRooms,
|
|
|
|
behaviour: .recurringOnActive
|
2022-10-21 08:32:51 +02:00
|
|
|
).migrationSafeInserted(db)
|
2022-05-29 11:26:06 +02:00
|
|
|
|
|
|
|
_ = try Job(
|
|
|
|
variant: .garbageCollection,
|
2022-07-01 04:52:41 +02:00
|
|
|
behaviour: .recurringOnActive
|
2022-10-21 08:32:51 +02:00
|
|
|
).migrationSafeInserted(db)
|
2022-04-21 08:42:35 +02:00
|
|
|
}
|
2022-06-01 08:50:21 +02:00
|
|
|
|
2022-07-01 05:08:45 +02:00
|
|
|
Storage.update(progress: 1, for: self, in: target) // In case this is the last migration
|
2022-04-21 08:42:35 +02:00
|
|
|
}
|
|
|
|
}
|