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

Conversation

ptoffy
Copy link
Member

@ptoffy ptoffy commented Jun 25, 2024

No description provided.

@ptoffy ptoffy requested a review from gwynne as a code owner June 25, 2024 17:01
Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.07%. Comparing base (0ecd6fa) to head (26d3331).

Additional details and impacted files
@@           Coverage Diff           @@
##             main       #8   +/-   ##
=======================================
  Coverage   92.07%   92.07%           
=======================================
  Files           7        7           
  Lines         227      227           
=======================================
  Hits          209      209           
  Misses         18       18           
Files Coverage Δ
Sources/QueuesFluentDriver/JobModelMigrate.swift 100.00% <100.00%> (ø)

Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

You don't need to explicitly declare the column NULL (not to mention you're then disabling the logic that specifies the correct database-specific name for timestamp columns), just add the default.

Comment on lines +27 to +36
.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))
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))

@ptoffy
Copy link
Member Author

ptoffy commented Jun 26, 2024

Superseded by bc47078

@ptoffy ptoffy closed this Jun 26, 2024
@ptoffy ptoffy deleted the nullable-timestamp branch June 26, 2024 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants