Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make timestamps nullable in MySQL 5.7 #8

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Sources/QueuesFluentDriver/JobModelMigrate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import protocol SQLKit.SQLDatabase
import struct SQLKit.SQLRaw
import enum SQLKit.SQLLiteral

public struct JobModelMigration: AsyncSQLMigration {
/// Public initializer.
Expand All @@ -23,16 +24,16 @@ public struct JobModelMigration: AsyncSQLMigration {
}

try await database.create(table: JobModel.schema)
.column("id", type: .text, .primaryKey(autoIncrement: false))
.column("queue_name", type: .text, .notNull)
.column("job_name", type: .text, .notNull)
.column("queued_at", type: .timestamp, .notNull)
.column("delay_until", type: .timestamp)
.column("state", type: .custom(SQLRaw(stateEnumType)), .notNull)
.column("max_retry_count", type: .int, .notNull)
.column("attempts", type: .int, .notNull)
.column("payload", type: .blob, .notNull)
.column("updated_at", type: .timestamp)
.column("id", type: .text, .primaryKey(autoIncrement: false))
.column("queue_name", type: .text, .notNull)
.column("job_name", type: .text, .notNull)
.column("queued_at", type: .timestamp, .notNull)
.column("delay_until", type: .custom(SQLRaw("TIMESTAMP NULL")), .default(SQLLiteral.null))
.column("state", type: .custom(SQLRaw(stateEnumType)), .notNull)
.column("max_retry_count", type: .int, .notNull)
.column("attempts", type: .int, .notNull)
.column("payload", type: .blob, .notNull)
.column("updated_at", type: .custom(SQLRaw("TIMESTAMP NULL")), .default(SQLLiteral.null))
Comment on lines +27 to +36
Copy link
Member

@gwynne gwynne Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.column("id", type: .text, .primaryKey(autoIncrement: false))
.column("queue_name", type: .text, .notNull)
.column("job_name", type: .text, .notNull)
.column("queued_at", type: .timestamp, .notNull)
.column("delay_until", type: .custom(SQLRaw("TIMESTAMP NULL")), .default(SQLLiteral.null))
.column("state", type: .custom(SQLRaw(stateEnumType)), .notNull)
.column("max_retry_count", type: .int, .notNull)
.column("attempts", type: .int, .notNull)
.column("payload", type: .blob, .notNull)
.column("updated_at", type: .custom(SQLRaw("TIMESTAMP NULL")), .default(SQLLiteral.null))
.column("id", type: .text, .primaryKey(autoIncrement: false))
.column("queue_name", type: .text, .notNull)
.column("job_name", type: .text, .notNull)
.column("queued_at", type: .timestamp, .notNull)
.column("delay_until", type: .timestamp, .default(SQLLiteral.null))
.column("state", type: .custom(SQLRaw(stateEnumType)), .notNull)
.column("max_retry_count", type: .int, .notNull)
.column("attempts", type: .int, .notNull)
.column("payload", type: .blob, .notNull)
.column("updated_at", type: .timestamp, .default(SQLLiteral.null))

.run()
try await database.create(index: "i_\(JobModel.schema)_state_queue_delayUntil")
.on(JobModel.schema)
Expand Down
Loading