-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on the upcoming support for tasks backed by custom enumerators surfaced the need for non-numeric cursors. For instance, one might have a task that iterates over resources backed by some API providing its own opaque string cursor, which would be impossible to serialize to a bigint column. As such, this changes the maintenance_tasks_runs.cursor column to be a string. For this to work, we must deserialize the cursor back to an integer in the Array and CSV collection cases, while the ActiveRecord case is handled transparently. Co-authored-by: Adrianna Chang <[email protected]> Co-authored-by: Sam Bostock <[email protected]>
- Loading branch information
1 parent
eeee3f4
commit 5d107fe
Showing
4 changed files
with
26 additions
and
6 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
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,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class ChangeCursorToString < ActiveRecord::Migration[6.0] | ||
# This migration will clear all existing data in the cursor column for | ||
# both MySQL and PostgresQL. Ensure no Tasks are paused when this migration | ||
# is deployed, or they will be resumed from the start. | ||
# Running tasks are able to gracefully handle this change, even if | ||
# interrupted. | ||
def up | ||
change_table(:maintenance_tasks_runs) do |t| | ||
t.change(:cursor, :string) | ||
end | ||
end | ||
|
||
def down | ||
change_table(:maintenance_tasks_runs) do |t| | ||
t.change(:cursor, :bigint) | ||
end | ||
end | ||
end |
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