-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert migrations in tests, don't flag migrations as complete in a re…
…vert
- Loading branch information
1 parent
3c94c17
commit 345f0b6
Showing
5 changed files
with
87 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Sources/HummingbirdJobsPostgres/Migrations/CreateJobs.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Hummingbird server framework project | ||
// | ||
// Copyright (c) 2024 the Hummingbird authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import HummingbirdPostgres | ||
import Logging | ||
@_spi(ConnectionPool) import PostgresNIO | ||
|
||
struct CreateJobs: HBPostgresMigration { | ||
func apply(connection: PostgresConnection, logger: Logger) async throws { | ||
try await connection.query( | ||
""" | ||
CREATE TABLE IF NOT EXISTS _hb_jobs ( | ||
id uuid PRIMARY KEY, | ||
job bytea, | ||
status smallint, | ||
lastModified TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP | ||
) | ||
""", | ||
logger: logger | ||
) | ||
} | ||
|
||
func revert(connection: PostgresConnection, logger: Logger) async throws { | ||
try await connection.query( | ||
"DROP TABLE _hb_jobs", | ||
logger: logger | ||
) | ||
} | ||
|
||
var name: String { "_Create_Jobs_Table_" } | ||
var group: HBMigrationGroup { .jobQueue } | ||
} | ||
|
||
extension HBMigrationGroup { | ||
/// JobQueue migration group | ||
public static var jobQueue: Self { .init("_hb_jobqueue") } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters