Skip to content

Commit

Permalink
Make deprecated HB symbols unavailable (#19)
Browse files Browse the repository at this point in the history
* Replace deprecated with unavailable

* Add revertLast

* Update Sources/HummingbirdFluent/Fluent.swift

* Use hummingbird 2.0.0-rc.1
  • Loading branch information
adam-fowler committed Jul 1, 2024
1 parent 53d2218 commit 0e113b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-beta.1"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0-rc.1"),
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.1"),
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.0.0"),
// used in tests
Expand Down
8 changes: 3 additions & 5 deletions Sources/HummingbirdFluent/Deprecations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
//
//===----------------------------------------------------------------------===//

// Below is a list of deprecated symbols with the "HB" prefix. These are available
// Below is a list of unavailable symbols with the "HB" prefix. These are available
// temporarily to ease transition from the old symbols that included the "HB"
// prefix to the new ones.
//
// This file will be removed before we do a 2.0 release

@_documentation(visibility: internal) @available(*, deprecated, renamed: "Fluent")
@_documentation(visibility: internal) @available(*, unavailable, renamed: "Fluent")
public typealias HBFluent = Fluent
@_documentation(visibility: internal) @available(*, deprecated, renamed: "FluentPersistDriver")
@_documentation(visibility: internal) @available(*, unavailable, renamed: "FluentPersistDriver")
public typealias HBFluentPersistDriver = FluentPersistDriver
18 changes: 17 additions & 1 deletion Sources/HummingbirdFluent/Fluent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct Fluent: Sendable, Service {

/// Manage Fluent database migrations
public actor FluentMigrations {
let migrations: Migrations
public let migrations: Migrations

init() {
self.migrations = .init()
Expand All @@ -106,6 +106,7 @@ public actor FluentMigrations {
/// - Parameters:
/// - migrations: Migrations array
/// - id: database id
@inlinable
public func add(_ migrations: [Migration], to id: DatabaseID? = nil) {
self.migrations.add(migrations, to: id)
}
Expand Down Expand Up @@ -139,4 +140,19 @@ public actor FluentMigrations {
try await migrator.setupIfNeeded().get()
try await migrator.revertAllBatches().get()
}

/// Revert last batch of fluent database migrations
/// - Parameters:
/// - databases: List of databases on which to revert migrations
/// - logger: Logger to use
public func revertLast(databases: Databases, logger: Logger) async throws {
let migrator = Migrator(
databases: databases,
migrations: self.migrations,
logger: logger,
on: databases.eventLoopGroup.any()
)
try await migrator.setupIfNeeded().get()
try await migrator.revertLastBatch().get()
}
}
1 change: 0 additions & 1 deletion Tests/HummingbirdFluentTests/FluentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import HummingbirdTesting
import Logging
import XCTest

@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
final class FluentTests: XCTestCase {
final class Planet: Model, ResponseCodable, @unchecked Sendable {
// Name of the table or collection.
Expand Down

0 comments on commit 0e113b7

Please sign in to comment.