migration for mono store

multistore
Laurent 1 year ago
parent b99883732b
commit 00a1ccf5f5
  1. 1
      PadelClub/Data/Club.swift
  2. 1
      PadelClub/Data/Court.swift
  3. 1
      PadelClub/Data/DateInterval.swift
  4. 1
      PadelClub/Data/Event.swift
  5. 1
      PadelClub/Data/GroupStage.swift
  6. 1
      PadelClub/Data/Match.swift
  7. 1
      PadelClub/Data/MatchScheduler.swift
  8. 1
      PadelClub/Data/MonthData.swift
  9. 1
      PadelClub/Data/PlayerRegistration.swift
  10. 1
      PadelClub/Data/Round.swift
  11. 1
      PadelClub/Data/TeamRegistration.swift
  12. 1
      PadelClub/Data/TeamScore.swift
  13. 7
      PadelClub/Data/Tournament.swift
  14. 2
      PadelClub/Data/TournamentStore.swift
  15. 3
      PadelClub/Data/User.swift
  16. 1
      PadelClub/Views/Tournament/Subscription/Purchase.swift

@ -15,6 +15,7 @@ class Club : ModelObject, Storable, Hashable {
static func resourceName() -> String { return "clubs" } static func resourceName() -> String { return "clubs" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [.get] } static func tokenExemptedMethods() -> [HTTPMethod] { return [.get] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
static func == (lhs: Club, rhs: Club) -> Bool { static func == (lhs: Club, rhs: Club) -> Bool {
lhs.id == rhs.id lhs.id == rhs.id

@ -14,6 +14,7 @@ class Court : ModelObject, Storable, Hashable {
static func resourceName() -> String { return "courts" } static func resourceName() -> String { return "courts" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
static func == (lhs: Court, rhs: Court) -> Bool { static func == (lhs: Court, rhs: Court) -> Bool {
lhs.id == rhs.id lhs.id == rhs.id

@ -14,6 +14,7 @@ class DateInterval: ModelObject, Storable {
static func resourceName() -> String { return "date-intervals" } static func resourceName() -> String { return "date-intervals" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()
var event: String var event: String

@ -15,6 +15,7 @@ class Event: ModelObject, Storable {
static func resourceName() -> String { return "events" } static func resourceName() -> String { return "events" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()
var creator: String? var creator: String?

@ -15,6 +15,7 @@ class GroupStage: ModelObject, Storable {
static func resourceName() -> String { "group-stages" } static func resourceName() -> String { "group-stages" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return true } static func filterByStoreIdentifier() -> Bool { return true }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()
var tournament: String var tournament: String

@ -13,6 +13,7 @@ class Match: ModelObject, Storable {
static func resourceName() -> String { "matches" } static func resourceName() -> String { "matches" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return true } static func filterByStoreIdentifier() -> Bool { return true }
static var relationshipNames: [String] = ["round", "groupStage"]
static func setServerTitle(upperRound: Round, matchIndex: Int) -> String { static func setServerTitle(upperRound: Round, matchIndex: Int) -> String {
if upperRound.index == 0 { return upperRound.roundTitle() } if upperRound.index == 0 { return upperRound.roundTitle() }

@ -15,6 +15,7 @@ class MatchScheduler : ModelObject, Storable {
static func resourceName() -> String { return "match-scheduler" } static func resourceName() -> String { return "match-scheduler" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
private(set) var id: String = Store.randomId() private(set) var id: String = Store.randomId()
var tournament: String var tournament: String

@ -15,6 +15,7 @@ class MonthData : ModelObject, Storable {
static func resourceName() -> String { return "month-data" } static func resourceName() -> String { return "month-data" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
private(set) var id: String = Store.randomId() private(set) var id: String = Store.randomId()
private(set) var monthKey: String private(set) var monthKey: String

@ -13,6 +13,7 @@ class PlayerRegistration: ModelObject, Storable {
static func resourceName() -> String { "player-registrations" } static func resourceName() -> String { "player-registrations" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return true } static func filterByStoreIdentifier() -> Bool { return true }
static var relationshipNames: [String] = ["teamRegistration"]
var id: String = Store.randomId() var id: String = Store.randomId()
var teamRegistration: String? var teamRegistration: String?

@ -14,6 +14,7 @@ class Round: ModelObject, Storable {
static func resourceName() -> String { "rounds" } static func resourceName() -> String { "rounds" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return true } static func filterByStoreIdentifier() -> Bool { return true }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()
var tournament: String var tournament: String

@ -13,6 +13,7 @@ class TeamRegistration: ModelObject, Storable {
static func resourceName() -> String { "team-registrations" } static func resourceName() -> String { "team-registrations" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return true } static func filterByStoreIdentifier() -> Bool { return true }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()
var tournament: String var tournament: String

@ -14,6 +14,7 @@ class TeamScore: ModelObject, Storable {
static func resourceName() -> String { "team-scores" } static func resourceName() -> String { "team-scores" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return true } static func filterByStoreIdentifier() -> Bool { return true }
static var relationshipNames: [String] = ["match"]
var id: String = Store.randomId() var id: String = Store.randomId()
var match: String var match: String

@ -13,6 +13,7 @@ class Tournament : ModelObject, Storable {
static func resourceName() -> String { "tournaments" } static func resourceName() -> String { "tournaments" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()
var event: String? var event: String?
@ -1897,13 +1898,13 @@ defer {
DataStore.shared.tournaments.writeChangeAndInsertOnServer(instance: self) DataStore.shared.tournaments.writeChangeAndInsertOnServer(instance: self)
for teamRegistration in self.unsortedTeams() { for teamRegistration in self.unsortedTeams() {
try teamRegistration.insertOnServer() teamRegistration.insertOnServer()
} }
for groupStage in self.groupStages() { for groupStage in self.groupStages() {
try groupStage.insertOnServer() groupStage.insertOnServer()
} }
for round in self.allRounds() { for round in self.allRounds() {
try round.insertOnServer() round.insertOnServer()
} }
} }

@ -44,9 +44,9 @@ class TournamentStore: Store, ObservableObject {
#endif #endif
self.groupStages = self.registerCollection(synchronized: synchronized, indexed: indexed) self.groupStages = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.rounds = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.teamRegistrations = self.registerCollection(synchronized: synchronized, indexed: indexed) self.teamRegistrations = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.playerRegistrations = self.registerCollection(synchronized: synchronized, indexed: indexed) self.playerRegistrations = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.rounds = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.matches = self.registerCollection(synchronized: synchronized, indexed: indexed) self.matches = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.teamScores = self.registerCollection(synchronized: synchronized, indexed: indexed) self.teamScores = self.registerCollection(synchronized: synchronized, indexed: indexed)
self.matchSchedulers = self.registerCollection(synchronized: false, indexed: indexed) self.matchSchedulers = self.registerCollection(synchronized: false, indexed: indexed)

@ -20,8 +20,7 @@ class User: ModelObject, UserBase, Storable {
static func resourceName() -> String { "users" } static func resourceName() -> String { "users" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] } static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
// func deleteDependencies() throws { }
public var id: String = Store.randomId() public var id: String = Store.randomId()
public var username: String public var username: String

@ -12,6 +12,7 @@ class Purchase: ModelObject, Storable {
static func resourceName() -> String { return "purchases" } static func resourceName() -> String { return "purchases" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] } static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false } static func filterByStoreIdentifier() -> Bool { return false }
static var relationshipNames: [String] = []
var id: String = Store.randomId() var id: String = Store.randomId()

Loading…
Cancel
Save