Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Modules/Sources/Storage/GRDB/Model/PersistedProduct.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedProduct: Codable {
public let id: Int64
public let siteID: Int64
Expand Down Expand Up @@ -48,6 +49,7 @@ public struct PersistedProduct: Codable {
}
}

// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProduct: FetchableRecord, PersistableRecord {
public static var databaseTableName: String { "product" }

Expand All @@ -72,6 +74,7 @@ extension PersistedProduct: FetchableRecord, PersistableRecord {
public static let attributes = hasMany(PersistedProductAttribute.self)
}

// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedProduct {
enum CodingKeys: String, CodingKey {
case id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedProductAttribute: Codable {
public private(set) var id: Int64?
public let productID: Int64
Expand All @@ -27,6 +28,7 @@ public struct PersistedProductAttribute: Codable {
}
}

// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductAttribute: FetchableRecord, MutablePersistableRecord {
public static var databaseTableName: String { "productAttribute" }

Expand All @@ -46,6 +48,7 @@ extension PersistedProductAttribute: FetchableRecord, MutablePersistableRecord {
}


// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedProductAttribute {
enum CodingKeys: String, CodingKey {
case id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedProductImage: Codable {
public let id: Int64
public let productID: Int64
Expand All @@ -27,6 +28,7 @@ public struct PersistedProductImage: Codable {
}
}

// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductImage: FetchableRecord, PersistableRecord {
public static var databaseTableName: String { "productImage" }

Expand All @@ -42,6 +44,7 @@ extension PersistedProductImage: FetchableRecord, PersistableRecord {
}


// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedProductImage {
enum CodingKeys: String, CodingKey {
case id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedProductVariation: Codable {
public let id: Int64
public let siteID: Int64
Expand Down Expand Up @@ -39,6 +40,7 @@ public struct PersistedProductVariation: Codable {
}
}

// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductVariation: FetchableRecord, PersistableRecord {
public static var databaseTableName: String { "productVariation" }

Expand All @@ -56,11 +58,12 @@ extension PersistedProductVariation: FetchableRecord, PersistableRecord {
static let stockStatusKey = Column(CodingKeys.stockStatusKey)
}

public static let attributes = hasMany(PersistedProductVariationAttribute.self)
public static let image = hasOne(PersistedProductVariationImage.self)
public static let attributes = hasMany(PersistedProductVariationAttribute.self).forKey("attributes")
public static let image = hasOne(PersistedProductVariationImage.self).forKey("image")
}


// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedProductVariation {
enum CodingKeys: String, CodingKey {
case id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedProductVariationAttribute: Codable {
public private(set) var id: Int64?
public let productVariationID: Int64
Expand All @@ -18,6 +19,8 @@ public struct PersistedProductVariationAttribute: Codable {
}
}

// periphery:ignore - TODO: remove ignore when populating database
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductVariationAttribute: FetchableRecord, MutablePersistableRecord {
public static var databaseTableName: String { "productVariationAttribute" }

Expand All @@ -34,6 +37,7 @@ extension PersistedProductVariationAttribute: FetchableRecord, MutablePersistabl
}


// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedProductVariationAttribute {
enum CodingKeys: String, CodingKey {
case id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedProductVariationImage: Codable {
public let id: Int64
public let productVariationID: Int64
Expand All @@ -27,6 +28,7 @@ public struct PersistedProductVariationImage: Codable {
}
}

// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductVariationImage: FetchableRecord, PersistableRecord {
public static var databaseTableName: String { "productVariationImage" }

Expand All @@ -42,6 +44,7 @@ extension PersistedProductVariationImage: FetchableRecord, PersistableRecord {
}


// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedProductVariationImage {
enum CodingKeys: String, CodingKey {
case id
Expand Down
6 changes: 6 additions & 0 deletions Modules/Sources/Storage/GRDB/Model/PersistedSite.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import Foundation
import GRDB

// periphery:ignore - TODO: remove ignore when populating database
public struct PersistedSite: Codable {
// periphery:ignore - TODO: remove ignore when populating database
public let id: Int64

// periphery:ignore - TODO: remove ignore when populating database
public init(id: Int64) {
self.id = id
}
}

// periphery:ignore - TODO: remove ignore when populating database
extension PersistedSite: FetchableRecord, PersistableRecord {
public static var databaseTableName: String { "site" }

public enum Columns {
// periphery:ignore - TODO: remove ignore when populating database
static let id = Column(CodingKeys.id)
}
}

// periphery:ignore - TODO: remove ignore when populating database
private extension PersistedSite {
enum CodingKeys: String, CodingKey {
case id
Expand Down
1 change: 1 addition & 0 deletions Modules/Sources/Storage/Protocols/Object.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public protocol Object: AnyObject {

/// Returns an instance of ObjectID: expected to identify the current instance, unequivocally.
///
// periphery:ignore - Used in tests, no changes but mysteriously stopped being ignored.
var objectID: ObjectID { get }

/// Returns the receiver's Entity Name.
Expand Down
7 changes: 7 additions & 0 deletions Modules/Sources/Yosemite/Model/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,19 @@ public typealias StorageWooShippingShipment = Storage.WooShippingShipment
public typealias StorageWooShippingOriginAddress = Storage.WooShippingOriginAddress

// MARK: - GRDB Persisted Models
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedSite = Storage.PersistedSite
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedProduct = Storage.PersistedProduct
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedProductAttribute = Storage.PersistedProductAttribute
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedProductImage = Storage.PersistedProductImage
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedProductVariation = Storage.PersistedProductVariation
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedProductVariationAttribute = Storage.PersistedProductVariationAttribute
// periphery:ignore - TODO: remove ignore when populating database
public typealias PersistedProductVariationImage = Storage.PersistedProductVariationImage

// MARK: - Internal ReadOnly Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import Storage

// MARK: - PersistedProduct Conversions
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProduct {
init(from posProduct: POSProduct) {
self.init(
Expand Down Expand Up @@ -59,6 +60,7 @@ extension PersistedProduct {
}

// MARK: - POSProduct Storage Extensions
// periphery:ignore - TODO: remove ignore when populating database
extension POSProduct {
public func save(to db: GRDBDatabaseConnection) throws {
try db.write { db in
Expand All @@ -81,6 +83,7 @@ extension POSProduct {
}

// MARK: - PersistedProductAttribute Conversions
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductAttribute {
init(from productAttribute: ProductAttribute, productID: Int64) {
self.init(
Expand All @@ -107,6 +110,7 @@ extension PersistedProductAttribute {
}

// MARK: - PersistedProductImage Conversions
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductImage {
init(from productImage: ProductImage, productID: Int64) {
self.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import Storage

// MARK: - PersistedProductVariation Conversions
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductVariation {
init(from posProductVariation: POSProductVariation) {
self.init(
Expand Down Expand Up @@ -53,6 +54,7 @@ extension PersistedProductVariation {
}

// MARK: - POSProductVariation Storage Extensions
// periphery:ignore - TODO: remove ignore when populating database
extension POSProductVariation {
public func save(to db: GRDBDatabaseConnection) throws {
try db.write { db in
Expand All @@ -75,6 +77,7 @@ extension POSProductVariation {
}

// MARK: - PersistedProductVariationAttribute Conversions
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductVariationAttribute {
init(from productVariationAttribute: ProductVariationAttribute, productVariationID: Int64) {
self.init(
Expand All @@ -94,6 +97,7 @@ extension PersistedProductVariationAttribute {
}

// MARK: - PersistedProductVariationImage Conversions
// periphery:ignore - TODO: remove ignore when populating database
extension PersistedProductVariationImage {
public init(from productImage: ProductImage, productVariationID: Int64) {
self.init(
Expand Down
Loading