-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateJobs.swift
48 lines (43 loc) · 1.43 KB
/
CreateJobs.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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_pg_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_pg_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") }
}