Skip to content

Commit 8fc37b1

Browse files
committed
Lower minimum macOS platform requirement, since we don't actually require something newer. Add AsyncSQLMigration.
1 parent 98da8fa commit 8fc37b1

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PackageDescription
44
let package = Package(
55
name: "sql-kit-extras",
66
platforms: [
7-
.macOS(.v13),
7+
.macOS(.v10_15),
88
],
99
products: [
1010
.library(name: "SQLKitExtras", targets: ["SQLKitExtras"]),

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PackageDescription
44
let package = Package(
55
name: "sql-kit-extras",
66
platforms: [
7-
.macOS(.v13),
7+
.macOS(.v10_15),
88
],
99
products: [
1010
.library(name: "SQLKitExtras", targets: ["SQLKitExtras"]),
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import protocol SQLKit.SQLDatabase
2+
import protocol FluentKit.Database
3+
import protocol FluentKit.AsyncMigration
4+
5+
/// A variant of `AsyncMigration` designed to simplify using SQLKit to write migrations.
6+
///
7+
/// > Warning: Use of ``AsyncSQLMigration`` will cause runtime errors if the migration is added to a Fluent
8+
/// > database which is not compatible with SQLKit (such as MongoDB).
9+
public protocol AsyncSQLMigration: AsyncMigration {
10+
/// Perform the desired migration.
11+
///
12+
/// - Parameter database: The database to migrate.
13+
func prepare(on database: any SQLDatabase) async throws
14+
15+
/// Reverse, if possible, the migration performed by `prepare(on:)`.
16+
///
17+
/// It is not uncommon for a given migration to be lossy if run in reverse, or to be irreversible in the
18+
/// entire. While it is recommended that such a migration throw an error (thus stopping any further progression
19+
/// of the revert operation), there is no requirement that it do so. In practice, most irreversible migrations
20+
/// choose to simply do nothing at all in this method. Implementors should carefully consider the consequences
21+
/// of progressively older migrations attempting to revert themselves afterwards before leaving this method blank.
22+
///
23+
/// - Parameter database: The database to revert.
24+
func revert(on database: any SQLDatabase) async throws
25+
}
26+
27+
extension AsyncSQLMigration {
28+
// See `AsyncMigration.prepare(on:)`.
29+
public func prepare(on database: any Database) async throws {
30+
try await self.prepare(on: database as! any SQLDatabase)
31+
}
32+
33+
// See `AsyncMigration.revert(on:)`.
34+
public func revert(on database: any Database) async throws {
35+
try await self.revert(on: database as! any SQLDatabase)
36+
}
37+
}

0 commit comments

Comments
 (0)