Skip to content
Snippets Groups Projects
Commit da5cf239 authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Included migration

parent 93e5b4dd
No related branches found
No related tags found
2 merge requests!40v1.1.2b166,!38Using new database structure
.build
.DS_Store .DS_Store
*.xcuserstate *.xcuserstate
xcuserdata/ xcuserdata/
......
...@@ -51,10 +51,6 @@ let package = Package( ...@@ -51,10 +51,6 @@ let package = Package(
.library(name: "DependencyInjection", targets: ["DependencyInjection"]) .library(name: "DependencyInjection", targets: ["DependencyInjection"])
], ],
dependencies: [ dependencies: [
.package(
url: "https://git.xx.network/elixxir/client-ios-db.git",
revision: "eb071f08000b2b7646e45e7a5f55bdc9ad6dbcfa"
),
.package(url: "https://github.com/Quick/Quick", from: "3.0.0"), .package(url: "https://github.com/Quick/Quick", from: "3.0.0"),
.package(url: "https://github.com/Quick/Nimble", from: "9.0.0"), .package(url: "https://github.com/Quick/Nimble", from: "9.0.0"),
.package(url: "https://github.com/SnapKit/SnapKit", from: "5.0.1"), .package(url: "https://github.com/SnapKit/SnapKit", from: "5.0.1"),
...@@ -70,6 +66,7 @@ let package = Package( ...@@ -70,6 +66,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/combine-schedulers", from: "0.5.0"), .package(url: "https://github.com/pointfreeco/combine-schedulers", from: "0.5.0"),
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.2.1"), .package(url: "https://github.com/kishikawakatsumi/KeychainAccess", from: "4.2.1"),
.package(url: "https://github.com/google/google-api-objectivec-client-for-rest", from: "1.6.0"), .package(url: "https://github.com/google/google-api-objectivec-client-for-rest", from: "1.6.0"),
.package(url: "https://git.xx.network/elixxir/client-ios-db.git", .upToNextMajor(from: "1.0.1")),
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", .upToNextMajor(from: "8.10.0")), .package(url: "https://github.com/firebase/firebase-ios-sdk.git", .upToNextMajor(from: "8.10.0")),
.package(url: "https://github.com/pointfreeco/swift-composable-architecture.git",.upToNextMajor(from: "0.32.0")) .package(url: "https://github.com/pointfreeco/swift-composable-architecture.git",.upToNextMajor(from: "0.32.0"))
], ],
...@@ -358,6 +355,10 @@ let package = Package( ...@@ -358,6 +355,10 @@ let package = Package(
.product( .product(
name: "XXDatabase", name: "XXDatabase",
package: "client-ios-db" package: "client-ios-db"
),
.product(
name: "XXLegacyDatabaseMigrator",
package: "client-ios-db"
) )
], ],
resources: [.process("Resources")] resources: [.process("Resources")]
......
import Retry import Retry
import os.log
import Models import Models
import Shared import Shared
import Combine import Combine
...@@ -6,12 +7,11 @@ import Defaults ...@@ -6,12 +7,11 @@ import Defaults
import XXModels import XXModels
import XXDatabase import XXDatabase
import Foundation import Foundation
import ToastFeature
import BackupFeature import BackupFeature
import NetworkMonitor import NetworkMonitor
import DependencyInjection import DependencyInjection
import XXLegacyDatabaseMigrator
import os.log
import ToastFeature
let logHandler = OSLog(subsystem: "xx.network", category: "Performance debugging") let logHandler = OSLog(subsystem: "xx.network", category: "Performance debugging")
...@@ -89,7 +89,24 @@ public final class Session: SessionType { ...@@ -89,7 +89,24 @@ public final class Session: SessionType {
os_signpost(.end, log: logHandler, name: "Decrypting", "Finished newClientFromBackup") os_signpost(.end, log: logHandler, name: "Decrypting", "Finished newClientFromBackup")
self.client = client self.client = client
dbManager = try Database.inMemory()
let oldPath = NSSearchPathForDirectoriesInDomains(
.documentDirectory, .userDomainMask, true
)[0].appending("/xxmessenger.sqlite")
let newPath = FileManager.default
.containerURL(forSecurityApplicationGroupIdentifier: "group.elixxir.messenger")!
.appendingPathComponent("database")
.appendingPathExtension("sqlite").path
try Migrator.live()(
try .init(path: oldPath),
to: try .onDisk(path: newPath),
myContactId: client.bindings.myId,
meMarshaled: client.bindings.meMarshalled
)
dbManager = try Database.onDisk(path: newPath)
let report = try! JSONDecoder().decode(BackupReport.self, from: backupData!) let report = try! JSONDecoder().decode(BackupReport.self, from: backupData!)
...@@ -111,7 +128,25 @@ public final class Session: SessionType { ...@@ -111,7 +128,25 @@ public final class Session: SessionType {
public init(ndf: String) throws { public init(ndf: String) throws {
let network = try! DependencyInjection.Container.shared.resolve() as XXNetworking let network = try! DependencyInjection.Container.shared.resolve() as XXNetworking
self.client = try network.newClient(ndf: ndf) self.client = try network.newClient(ndf: ndf)
dbManager = try Database.inMemory()
let oldPath = NSSearchPathForDirectoriesInDomains(
.documentDirectory, .userDomainMask, true
)[0].appending("/xxmessenger.sqlite")
let newPath = FileManager.default
.containerURL(forSecurityApplicationGroupIdentifier: "group.elixxir.messenger")!
.appendingPathComponent("database")
.appendingPathExtension("sqlite").path
try Migrator.live()(
try .init(path: oldPath),
to: try .onDisk(path: newPath),
myContactId: client.bindings.myId,
meMarshaled: client.bindings.meMarshalled
)
dbManager = try Database.onDisk(path: newPath)
try continueInitialization() try continueInitialization()
} }
......
...@@ -50,7 +50,8 @@ ...@@ -50,7 +50,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://git.xx.network/elixxir/client-ios-db.git", "location" : "https://git.xx.network/elixxir/client-ios-db.git",
"state" : { "state" : {
"revision" : "eb071f08000b2b7646e45e7a5f55bdc9ad6dbcfa" "revision" : "8674619071b9e2aa909b0626b0b37e64129c4841",
"version" : "1.0.1"
} }
}, },
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment