/
CreateJobQueue.swift
48 lines (44 loc) · 1.45 KB
/
CreateJobQueue.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 CreateJobQueue: PostgresMigration {
func apply(connection: PostgresConnection, logger: Logger) async throws {
try await connection.query(
"""
CREATE TABLE IF NOT EXISTS _hb_pg_job_queue (
job_id uuid PRIMARY KEY,
createdAt timestamp with time zone
)
""",
logger: logger
)
try await connection.query(
"""
CREATE INDEX IF NOT EXISTS _hb_job_queueidx
ON _hb_pg_job_queue (createdAt ASC)
""",
logger: logger
)
}
func revert(connection: PostgresConnection, logger: Logger) async throws {
try await connection.query(
"DROP TABLE _hb_pg_job_queue",
logger: logger
)
}
var name: String { "_Create_JobQueue_Table_" }
var group: MigrationGroup { .jobQueue }
}