Skip to content

Commit

Permalink
Merge pull request #58 from moneymanagerex/user_version
Browse files Browse the repository at this point in the history
Add user_version=19
  • Loading branch information
georgeef authored Sep 27, 2024
2 parents 37fe9f7 + ac4c650 commit ff50ad8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 1 addition & 4 deletions MMEX/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@ struct ContentView: View {
print("Unable to access file at URL: \(url)")
}
let repository = dataManager.repository
if let tables = Bundle.main.url(forResource: "tables.sql", withExtension: "") {
repository.execute(url: tables)
if isSampleDocument { repository.insertSampleData() }
}
repository.create(sampleData: isSampleDocument)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
selectedTab = 0
}
Expand Down
11 changes: 11 additions & 0 deletions MMEX/Repositories/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ extension Repository {
execute(sql: paragraph)
}
}

func create(sampleData: Bool = false) {
guard let db else { return }
db.userVersion = 19
guard let tables = Bundle.main.url(forResource: "tables.sql", withExtension: "") else {
print("Cannot find tables.sql")
return
}
execute(url: tables)
if sampleData { insertSampleData() }
}
}

protocol RepositoryProtocol {
Expand Down

0 comments on commit ff50ad8

Please sign in to comment.