Created
October 3, 2024 17:32
-
-
Save sorentwo/d9e14687024e87eb062db4a4abb7b5ee to your computer and use it in GitHub Desktop.
Departition Oban Jobs Table
This file contains hidden or 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
def up do | |
execute("LOCK TABLE oban_jobs") | |
execute("CREATE TABLE oban_jobs_temp AS TABLE oban_jobs") | |
execute("DROP TABLE oban_jobs CASCADE") | |
flush() | |
Oban.Migrations.up() | |
Oban.Pro.Migrations.Workflow.up() | |
Oban.Pro.Migrations.Batch.up() | |
execute(""" | |
INSERT INTO | |
oban_jobs | |
SELECT | |
id, | |
state, | |
queue, | |
worker, | |
args, | |
errors, | |
attempt, | |
max_attempts, | |
inserted_at, | |
scheduled_at, | |
attempted_at, | |
completed_at, | |
attempted_by, | |
discarded_at, | |
priority, | |
tags, | |
meta, | |
cancelled_at | |
FROM oban_jobs_temp | |
""") | |
execute("SELECT setval('oban_jobs_id_seq', max(id)) FROM oban_jobs") | |
execute("DROP TABLE oban_jobs_temp") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment