WIP: migrations demo

This commit is contained in:
John Estropia
2020-09-08 09:09:36 +09:00
parent 8d7f282743
commit 2bbf6b34ea
16 changed files with 199 additions and 16 deletions

View File

@@ -78,18 +78,6 @@ extension Menu {
)
}
Section(header: Text("Classic (NSManagedObject subclasses)")) {
Menu.ItemView(
title: "Placemarks",
subtitle: "Making changes using transactions in Swift",
destination: { EmptyView() }
)
.disabled(true)
Menu.ItemView(
title: "Time Zones",
subtitle: "Fetching objects and Querying raw values",
destination: { EmptyView() }
)
.disabled(true)
Menu.ItemView(
title: "Colors",
subtitle: "Observing list changes and single-object changes using ListMonitor",
@@ -104,16 +92,19 @@ extension Menu {
subtitle: "Switching between multiple persistent stores",
destination: { EmptyView() }
)
.disabled(true)
Menu.ItemView(
title: "Evolution",
subtitle: "Migrating and reverse-migrating stores",
destination: { EmptyView() }
)
.disabled(true)
Menu.ItemView(
title: "Logger",
subtitle: "Implementing a custom logger",
destination: { EmptyView() }
)
.disabled(true)
}
}
.listStyle(GroupedListStyle())

View File

@@ -0,0 +1,10 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
// MARK: - Advanced
/**
Sample application of complex use cases
*/
enum Advanced {}

View File

@@ -0,0 +1,5 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
import Foundation

View File

@@ -0,0 +1,27 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
import UIKit
import CoreStore
// MARK: - Advanced.EvolutionDemo
extension Advanced.EvolutionDemo {
// MARK: - Advanced.EvolutionDemo.CreatureV1
final class CreatureV1: CoreStoreObject {
// MARK: Internal
@Field.Stored("dnaCode")
var dnaCode: Int64 = 0
@Field.Stored("hasHead")
var hasHead: Bool = false
@Field.Stored("hasTail")
var hasTail: Bool = false
}
}

View File

@@ -0,0 +1,8 @@
//
// Advanced.Evolution.CreatureV2.swift
// Demo
//
// Created by John Rommel Estropia on 2020/09/06.
//
import Foundation

View File

@@ -0,0 +1,8 @@
//
// Advanced.Evolution.CreatureV3.swift
// Demo
//
// Created by John Rommel Estropia on 2020/09/06.
//
import Foundation

View File

@@ -0,0 +1,8 @@
//
// Advanced.Evolution.CreatureV4.swift
// Demo
//
// Created by John Rommel Estropia on 2020/09/06.
//
import Foundation

View File

@@ -0,0 +1,5 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
import Foundation

View File

@@ -0,0 +1,5 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
import Foundation

View File

@@ -0,0 +1,5 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
import Foundation

View File

@@ -0,0 +1,23 @@
//
// Demo
// Copyright © 2020 John Rommel Estropia, Inc. All rights reserved.
// MARK: - Advanced
extension Advanced {
// MARK: - Advanced.EvolutionDemo
/**
Sample execution of progressive migrations. This demo also supports backwards migration.
*/
enum EvolutionDemo: CaseIterable {
// MARK: Internal
case ageOfInvertebrates
case ageOfFishes
case ageOfReptiles
case ageOfMammals
}
}

View File

@@ -28,7 +28,7 @@ extension Classic.ColorsDemo {
switch self {
case .all: return .init()
case .light: return (\.brightness >= 0.9)
case .light: return (\.brightness >= 0.6)
case .dark: return (\.brightness <= 0.4)
}
}

View File

@@ -96,6 +96,6 @@ final class Classic_ColorsDemo_Palette: NSManagedObject {
private static func randomBrightness() -> Float {
return Float.random(in: 0.0 ... 1.0)
return Float.random(in: 0.1 ... 0.9)
}
}

View File

@@ -28,7 +28,7 @@ extension Modern.ColorsDemo {
switch self {
case .all: return .init()
case .light: return (\.$brightness >= 0.9)
case .light: return (\.$brightness >= 0.6)
case .dark: return (\.$brightness <= 0.4)
}
}

View File

@@ -137,7 +137,7 @@ extension Modern.ColorsDemo {
private static func randomBrightness() -> Float {
return Float.random(in: 0.0 ... 1.0)
return Float.random(in: 0.1 ... 0.9)
}
}
}