Skip to content

Commit

Permalink
refactor(ios): Replace Database with swift-utilities database packages
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed May 22, 2024
1 parent 813bdc9 commit 9ff2c8c
Show file tree
Hide file tree
Showing 84 changed files with 483 additions and 564 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"location" : "https://github.com/autoreleasefool/swift-utilities.git",
"state" : {
"branch" : "main",
"revision" : "da6794300b2f41ec925e3982def20b425626d41d"
"revision" : "dd5c96a6b4c42a70fbed62377da8b16d19eff58a"
}
},
{
Expand Down
22 changes: 9 additions & 13 deletions ios/Approach/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ let package = Package(
.library(name: "AssetsLibrary", targets: ["AssetsLibrary"]),
.library(name: "ComposableExtensionsLibrary", targets: ["ComposableExtensionsLibrary"]),
.library(name: "ConstantsLibrary", targets: ["ConstantsLibrary"]),
.library(name: "DatabaseLibrary", targets: ["DatabaseLibrary"]),
.library(name: "DatabaseMigrationsLibrary", targets: ["DatabaseMigrationsLibrary"]),
.library(name: "DatabaseModelsLibrary", targets: ["DatabaseModelsLibrary"]),
.library(name: "DateTimeLibrary", targets: ["DateTimeLibrary"]),
.library(name: "FeatureActionLibrary", targets: ["FeatureActionLibrary"]),
Expand Down Expand Up @@ -256,6 +256,7 @@ let package = Package(
.product(name: "BundlePackageService", package: "swift-utilities"),
.product(name: "FeatureFlagsPackageService", package: "swift-utilities"),
.product(name: "FileManagerPackageService", package: "swift-utilities"),
.product(name: "GRDBDatabasePackageService", package: "swift-utilities"),
.product(name: "PasteboardPackageService", package: "swift-utilities"),
.product(name: "SentryErrorReportingPackageService", package: "swift-utilities"),
.product(name: "StoreReviewPackageService", package: "swift-utilities"),
Expand Down Expand Up @@ -1220,17 +1221,17 @@ let package = Package(
.target(
name: "DatabaseService",
dependencies: [
.product(name: "FileManagerPackageServiceInterface", package: "swift-utilities"),
"AnalyticsServiceInterface",
"DatabaseLibrary",
"DatabaseMigrationsLibrary",
"DatabaseServiceInterface",
]
),
.target(
name: "DatabaseServiceInterface",
dependencies: [
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "DependenciesMacros", package: "swift-dependencies"),
.product(name: "GRDB", package: "GRDB.swift"),
.product(name: "GRDBDatabasePackageServiceInterface", package: "swift-utilities"),
]
),
.testTarget(
Expand Down Expand Up @@ -1497,21 +1498,15 @@ let package = Package(
]
),
.target(
name: "DatabaseLibrary",
name: "DatabaseMigrationsLibrary",
dependencies: [
.product(name: "Dependencies", package: "swift-dependencies"),
.product(name: "ErrorReportingClientPackageLibrary", package: "swift-utilities"),
.product(name: "GRDB", package: "GRDB.swift"),
.product(name: "GRDBDatabasePackageLibrary", package: "swift-utilities"),
"ScoreKeeperLibrary",
]
),
.testTarget(
name: "DatabaseLibraryTests",
dependencies: [
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
"DatabaseLibrary",
]
),
.target(
name: "DatabaseModelsLibrary",
dependencies: [
Expand Down Expand Up @@ -1814,7 +1809,8 @@ let package = Package(
.target(
name: "TestDatabaseUtilitiesLibrary",
dependencies: [
"DatabaseLibrary",
.product(name: "GRDBDatabaseTestUtilitiesPackageLibrary", package: "swift-utilities"),
"DatabaseMigrationsLibrary",
"DatabaseModelsLibrary",
]
),
Expand Down
28 changes: 20 additions & 8 deletions ios/Approach/Package.swift.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ supported = [ "\"17.0\"" ]
[features.App]
features = [ "AccessoriesOverview", "BowlersList", "Onboarding", "Settings", "StatisticsOverview" ]
services = [ "Launch" ]
dependencies = [ "AnalyticsPackageService", "AppInfoPackageService", "BundlePackageService", "FeatureFlagsPackageService", "FileManagerPackageService", "PasteboardPackageService", "SentryErrorReportingPackageService", "StoreReviewPackageService", "TelemetryDeckAnalyticsPackageService", "UserDefaultsPackageService" ]
dependencies = [ "AnalyticsPackageService", "AppInfoPackageService", "BundlePackageService", "FeatureFlagsPackageService", "FileManagerPackageService", "GRDBDatabasePackageService", "PasteboardPackageService", "SentryErrorReportingPackageService", "StoreReviewPackageService", "TelemetryDeckAnalyticsPackageService", "UserDefaultsPackageService" ]

[features.AccessoriesOverview]
features = [ "AlleysList", "GearList" ]
Expand Down Expand Up @@ -244,12 +244,10 @@ dependencies = [ "ExtensionsPackageLibrary" ]
libraries = [ "ModelsViews" ]

[services.Database]
libraries = [ "Database" ]
services = [ "Analytics" ]
dependencies = [ "FileManagerPackageServiceInterface" ]
libraries = [ "DatabaseMigrations" ]
[services.Database.interface]
suitable_for_dependents_matching = "\\w+Repository$"
dependencies = [ "GRDB" ]
dependencies = [ "DependenciesMacros", "GRDB", "GRDBDatabasePackageServiceInterface" ]

[services.DatabaseMocking]
skip_tests = true
Expand Down Expand Up @@ -319,9 +317,10 @@ dependencies = [ "Dependencies" ]
[libraries.Constants.resources]
processed = [ "Resources" ]

[libraries.Database]
[libraries.DatabaseMigrations]
skip_tests = true
libraries = [ "ScoreKeeper" ]
dependencies = [ "Dependencies", "ErrorReportingClientPackageLibrary", "GRDB" ]
dependencies = [ "Dependencies", "ErrorReportingClientPackageLibrary", "GRDB", "GRDBDatabasePackageLibrary" ]

[libraries.DatabaseModels]
skip_tests = true
Expand Down Expand Up @@ -416,7 +415,8 @@ libraries = [ "StatisticsChartsMocks" ]
[libraries.TestDatabaseUtilities]
suitable_for_dependents_matching = "\\w+Tests$"
skip_tests = true
libraries = [ "Database", "DatabaseModels" ]
libraries = [ "DatabaseMigrations", "DatabaseModels" ]
dependencies = [ "GRDBDatabaseTestUtilitiesPackageLibrary" ]

[libraries.Tips]
libraries = [ "Views" ]
Expand Down Expand Up @@ -547,6 +547,18 @@ sharedRef = "SwiftUtilities"
[dependencies.FileManagerPackageServiceInterface]
sharedRef = "SwiftUtilities"

[dependencies.GRDBDatabasePackageLibrary]
sharedRef = "SwiftUtilities"

[dependencies.GRDBDatabasePackageService]
sharedRef = "SwiftUtilities"

[dependencies.GRDBDatabasePackageServiceInterface]
sharedRef = "SwiftUtilities"

[dependencies.GRDBDatabaseTestUtilitiesPackageLibrary]
sharedRef = "SwiftUtilities"

[dependencies.PasteboardPackageService]
sharedRef = "SwiftUtilities"

Expand Down
2 changes: 1 addition & 1 deletion ios/Approach/Sources/AlleysListFeature/AlleysList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public struct AlleysList: Reducer {
)

@Dependency(\.featureFlags) var featureFlags
self.isAlleyAndGearAveragesEnabled = try featureFlags.isFlagEnabled(.alleyAndGearAverages)
self.isAlleyAndGearAveragesEnabled = featureFlags.isFlagEnabled(.alleyAndGearAverages)
}
}

Expand Down
1 change: 1 addition & 0 deletions ios/Approach/Sources/AppFeature/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AppInfoPackageService
import BundlePackageService
import FeatureFlagsPackageService
import FileManagerPackageService
import GRDBDatabasePackageService
import PasteboardPackageService
import SentryErrorReportingPackageService
import StoreReviewPackageService
Expand Down
56 changes: 0 additions & 56 deletions ios/Approach/Sources/DatabaseLibrary/Migrations/DBMigration.swift

This file was deleted.

42 changes: 42 additions & 0 deletions ios/Approach/Sources/DatabaseMigrationsLibrary/Migrations.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import GRDB
import GRDBDatabasePackageLibrary

public enum Migrations {
public static var approachMigrations: [Migration.Type] {
[
Migration20230325CreateBowler.self,
Migration20230408CreateAlley.self,
Migration20230408CreateLeague.self,
Migration20230409CreateSeries.self,
Migration20230413CreateGear.self,
Migration20230414CreateGame.self,
Migration20230414CreateFrame.self,
Migration20230415CreateLane.self,
Migration20230417CreateSeriesLanePivot.self,
Migration20230425CreateAvatar.self,
Migration20230426CreateLocation.self,
Migration20230506AddGearToFrame.self,
Migration20230514CreateMatchPlay.self,
Migration20230519AddScoreToGame.self,
Migration20230531GameLanes.self,
Migration20230602AddGearToGame.self,
Migration20230630CreateStatisticsWidget.self,
Migration20230912CreateBowlerPreferredGear.self,
Migration20230913AddAvatarToGear.self,
Migration20230918ChangeWidgetSourceToColumns.self,
Migration20230918OnDeleteGearBowlerSetNull.self,
Migration20230918MigrateStatisticsWidgetType.self,
Migration20230920ValidateGameScores.self,
Migration20231002ValidateGameScores.self,
Migration20231022IsArchivedProperty.self,
Migration20231022DropSeriesNumberOfGames.self,
Migration20231023AddArchivePropertyToGame.self,
Migration20231024IsArchivedToArchivedOn.self,
Migration20231128AddDurationToGame.self,
Migration20231220MigrateRecurringLeagues.self,
Migration20231220RenameLeagueNumberOfGames.self,
Migration20240322AddBowledOnDateToSeries.self,
Migration20240329ClearExtraRolledBalls.self,
]
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230325CreateBowler: DBMigration {
struct Migration20230325CreateBowler: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "bowler") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230408CreateAlley: DBMigration {
struct Migration20230408CreateAlley: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "alley") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230408CreateLeague: DBMigration {
struct Migration20230408CreateLeague: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "league") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230409CreateSeries: DBMigration {
struct Migration20230409CreateSeries: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "series") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230413CreateGear: DBMigration {
struct Migration20230413CreateGear: Migration {
static func migrate(_ db: Database) throws {
// NOTE: Superceded in Migration20230918OnDeleteGearBowlerSetNull
try db.create(table: "gear") { t in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230414CreateFrame: DBMigration {
struct Migration20230414CreateFrame: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "frame") { t in
t.column("gameId", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230414CreateGame: DBMigration {
struct Migration20230414CreateGame: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "game") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230415CreateLane: DBMigration {
struct Migration20230415CreateLane: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "lane") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230417CreateSeriesLanePivot: DBMigration {
struct Migration20230417CreateSeriesLanePivot: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "seriesLane") { t in
t.column("seriesId", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230425CreateAvatar: DBMigration {
struct Migration20230425CreateAvatar: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "avatar") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230426CreateLocation: DBMigration {
struct Migration20230426CreateLocation: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "location") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230506AddGearToFrame: DBMigration {
struct Migration20230506AddGearToFrame: Migration {
static func migrate(_ db: Database) throws {
try db.alter(table: "frame") { t in
t.add(column: "ball0", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230514CreateMatchPlay: DBMigration {
struct Migration20230514CreateMatchPlay: Migration {
static func migrate(_ db: Database) throws {
try db.create(table: "matchPlay") { t in
t.column("id", .text)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230519AddScoreToGame: DBMigration {
struct Migration20230519AddScoreToGame: Migration {
static func migrate(_ db: Database) throws {
try db.alter(table: "game") { t in
t.drop(column: "manualScore")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GRDB
import GRDBDatabasePackageLibrary

struct Migration20230531GameLanes: DBMigration {
struct Migration20230531GameLanes: Migration {
static func migrate(_ db: Database) throws {
try db.drop(index: "league_on_alleyId")

Expand Down
Loading

0 comments on commit 9ff2c8c

Please sign in to comment.