Skip to content

Commit 76ec89f

Browse files
authored
Merge pull request #2 from zunda-pixel/add-any-keyword
update swift version to v6
2 parents 488dab4 + 29344cf commit 76ec89f

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ jobs:
2020
strategy:
2121
matrix:
2222
image:
23-
- 'swift:5.9'
24-
- 'swift:5.10'
2523
- 'swift:6.0'
24+
- 'swift:6.1'
25+
- 'swift:6.2'
2626
postgres-image:
2727
- 'postgres:17'
2828
- 'postgres:16'
@@ -68,7 +68,7 @@ jobs:
6868
-ignore-filename-regex="\/Benchmarks\/" \
6969
-instr-profile .build/debug/codecov/default.profdata > info.lcov
7070
- name: Upload to codecov.io
71-
uses: codecov/codecov-action@v5
71+
uses: codecov/codecov-action@v4
7272
with:
7373
files: info.lcov
7474
token: ${{ secrets.CODECOV_TOKEN }}

Package.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,42 @@
1-
// swift-tools-version: 5.9
1+
// swift-tools-version:6.0
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

6+
let swiftSettings: [SwiftSetting] = [
7+
// https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md
8+
.enableUpcomingFeature("ExistentialAny"),
9+
10+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0444-member-import-visibility.md
11+
.enableUpcomingFeature("MemberImportVisibility"),
12+
13+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0409-access-level-on-imports.md
14+
.enableUpcomingFeature("InternalImportsByDefault"),
15+
]
16+
617
let package = Package(
718
name: "postgres-migrations",
8-
platforms: [.macOS(.v14), .iOS(.v17), .tvOS(.v17)],
19+
platforms: [.macOS(.v14), .iOS(.v17), .macCatalyst(.v17), .tvOS(.v17), .visionOS(.v1)],
920
products: [
1021
.library(name: "PostgresMigrations", targets: ["PostgresMigrations"])
1122
],
1223
dependencies: [
13-
.package(url: "https://github.com/vapor/postgres-nio", from: "1.25.0")
24+
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.25.0")
1425
],
1526
targets: [
1627
.target(
1728
name: "PostgresMigrations",
1829
dependencies: [
1930
.product(name: "PostgresNIO", package: "postgres-nio")
20-
]
31+
],
32+
swiftSettings: swiftSettings
2133
),
2234
.testTarget(
2335
name: "PostgresMigrationsTests",
2436
dependencies: [
2537
"PostgresMigrations"
26-
]
38+
],
39+
swiftSettings: swiftSettings
2740
),
28-
],
29-
swiftLanguageVersions: [.v5, .version("6")]
41+
]
3042
)

Sources/PostgresMigrations/Migration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Logging
16-
import PostgresNIO
16+
public import PostgresNIO
1717

1818
/// Protocol for a database migration
1919
///

Sources/PostgresMigrations/MigrationService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Logging
16-
import PostgresNIO
17-
import ServiceLifecycle
16+
public import PostgresNIO
17+
public import ServiceLifecycle
1818

1919
/// Service that runs a database migration
2020
public struct DatabaseMigrationService: Service {

Sources/PostgresMigrations/Migrations.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Logging
16-
import PostgresNIO
16+
public import PostgresNIO
1717

1818
/// Database migration support
1919
public actor DatabaseMigrations {
2020
enum State {
21-
case waiting([CheckedContinuation<Void, Error>])
21+
case waiting([CheckedContinuation<Void, any Error>])
2222
case completed
23-
case failed(Error)
23+
case failed(any Error)
2424
}
2525

26-
var migrations: [DatabaseMigration]
27-
var reverts: [String: DatabaseMigration]
26+
var migrations: [any DatabaseMigration]
27+
var reverts: [String: any DatabaseMigration]
2828
var state: State
2929

3030
/// Initialize a DatabaseMigrations object
@@ -38,7 +38,7 @@ public actor DatabaseMigrations {
3838
/// - Parameters
3939
/// - migration: DatabaseMigration to be applied
4040
/// - skipDuplicates: Only add migration if it doesn't exist in the list
41-
public func add(_ migration: DatabaseMigration, skipDuplicates: Bool = false) {
41+
public func add(_ migration: any DatabaseMigration, skipDuplicates: Bool = false) {
4242
if skipDuplicates {
4343
let existingMigration = self.migrations.first {
4444
type(of: $0) == type(of: migration)
@@ -52,7 +52,7 @@ public actor DatabaseMigrations {
5252
///
5353
/// This is useful for migrations you might have to revert.
5454
/// - Parameter migration: DatabaseMigration to be registerd
55-
public func register(_ migration: DatabaseMigration) {
55+
public func register(_ migration: any DatabaseMigration) {
5656
self.reverts[migration.name] = migration
5757
}
5858

@@ -96,7 +96,7 @@ public actor DatabaseMigrations {
9696
groups.count == 0
9797
? (migrations.map(\.group) + appliedMigrations.map(\.group)).uniqueElements
9898
: groups
99-
var migrationsToApply: [DatabaseMigration] = .init()
99+
var migrationsToApply: [any DatabaseMigration] = .init()
100100
// for each group apply/revert migrations
101101
for group in groups {
102102
let groupMigrations = migrations.filter { $0.group == group }
@@ -180,7 +180,7 @@ public actor DatabaseMigrations {
180180
groups.count == 0
181181
? (migrations.map(\.group) + appliedMigrations.map(\.group)).uniqueElements
182182
: groups
183-
var migrationsToRevert: [DatabaseMigration] = .init()
183+
var migrationsToRevert: [any DatabaseMigration] = .init()
184184
// for each group revert migrations
185185
for group in groups {
186186
let appliedGroupMigrations = appliedMigrations.filter { $0.group == group }
@@ -255,7 +255,7 @@ public actor DatabaseMigrations {
255255
// get migrations currently applied in the order they were applied
256256
let appliedMigrations = try await repository.getAll(client: client, logger: logger)
257257

258-
var migrationsToRevert: [DatabaseMigration] = .init()
258+
var migrationsToRevert: [any DatabaseMigration] = .init()
259259
// if groups array passed in is empty then work out list of migration groups by combining
260260
// list of groups from migrations and applied migrations
261261
let groups =
@@ -338,7 +338,7 @@ public actor DatabaseMigrations {
338338
}
339339
}
340340

341-
func setFailed(_ error: Error) {
341+
func setFailed(_ error: any Error) {
342342
switch self.state {
343343
case .waiting(let continuations):
344344
for cont in continuations {
@@ -437,14 +437,14 @@ struct PostgresMigrationRepository: Sendable {
437437
try await self.createMigrationsTable(client: client, logger: logger)
438438
}
439439

440-
func add(_ migration: DatabaseMigration, context: Context) async throws {
440+
func add(_ migration: any DatabaseMigration, context: Context) async throws {
441441
try await context.connection.query(
442442
"INSERT INTO _hb_pg_migrations (\"name\", \"group\") VALUES (\(migration.name), \(migration.group.name))",
443443
logger: context.logger
444444
)
445445
}
446446

447-
func remove(_ migration: DatabaseMigration, context: Context) async throws {
447+
func remove(_ migration: any DatabaseMigration, context: Context) async throws {
448448
try await context.connection.query(
449449
"DELETE FROM _hb_pg_migrations WHERE name = \(migration.name)",
450450
logger: context.logger

Tests/PostgresMigrationsTests/MigrationTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Foundation
33
import Logging
44
import PostgresNIO
55
import ServiceLifecycle
6+
import UnixSignals
67
import XCTest
78

89
@testable import PostgresMigrations

0 commit comments

Comments
 (0)