2022-09-15 07:50:15 +02:00
|
|
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import GRDB
|
|
|
|
import SessionUtilitiesKit
|
|
|
|
|
|
|
|
enum _009_OpenGroupPermission: Migration {
|
|
|
|
static let target: TargetMigrations.Identifier = .messagingKit
|
2023-09-25 10:32:56 +02:00
|
|
|
static let identifier: String = "OpenGroupPermission" // stringlint:disable
|
2022-09-15 07:50:15 +02:00
|
|
|
static let needsConfigSync: Bool = false
|
2023-08-11 10:02:06 +02:00
|
|
|
static let minExpectedRunDuration: TimeInterval = 0.01
|
2023-10-03 03:52:29 +02:00
|
|
|
static let fetchedTables: [(TableRecord & FetchableRecord).Type] = []
|
|
|
|
static let createdOrAlteredTables: [(TableRecord & FetchableRecord).Type] = [OpenGroup.self]
|
2022-09-15 07:50:15 +02:00
|
|
|
|
|
|
|
static func migrate(_ db: GRDB.Database) throws {
|
|
|
|
try db.alter(table: OpenGroup.self) { t in
|
2022-09-15 08:49:39 +02:00
|
|
|
t.add(.permissions, .integer)
|
|
|
|
.defaults(to: OpenGroup.Permissions.all)
|
2022-09-15 07:50:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// When modifying OpenGroup behaviours we should always look to reset the `infoUpdates`
|
|
|
|
// value for all OpenGroups to ensure they all have the correct state for newly
|
|
|
|
// added/changed fields
|
|
|
|
_ = try OpenGroup
|
|
|
|
.updateAll(db, OpenGroup.Columns.infoUpdates.set(to: 0))
|
|
|
|
|
|
|
|
Storage.update(progress: 1, for: self, in: target) // In case this is the last migration
|
|
|
|
}
|
|
|
|
}
|