switchman-inst-jobs 1.4.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +42 -0
  3. data/db/migrate/20110208031356_add_delayed_jobs_tag.rb +14 -0
  4. data/db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb +13 -0
  5. data/db/migrate/20110516225834_add_delayed_jobs_strand.rb +14 -0
  6. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +26 -0
  7. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +40 -0
  8. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +52 -0
  9. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +31 -0
  10. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +15 -0
  11. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +80 -0
  12. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +15 -0
  13. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +15 -0
  14. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +13 -0
  15. data/db/migrate/20140505215131_add_failed_jobs_original_job_id.rb +13 -0
  16. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +12 -0
  17. data/db/migrate/20140505223637_drop_failed_jobs_original_id.rb +13 -0
  18. data/db/migrate/20140512213941_add_source_to_jobs.rb +15 -0
  19. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +70 -0
  20. data/db/migrate/20151123210429_add_expires_at_to_jobs.rb +15 -0
  21. data/db/migrate/20151210162949_improve_max_concurrent.rb +50 -0
  22. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +39 -0
  23. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +95 -0
  24. data/db/migrate/20190726154743_make_critical_columns_not_null.rb +15 -0
  25. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +25 -0
  26. data/db/migrate/20200818130101_add_on_hold_to_switchman_shards.rb +5 -0
  27. data/db/migrate/20200822014259_add_block_stranded_to_switchman_shards.rb +5 -0
  28. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +94 -0
  29. data/db/migrate/20200825011002_add_strand_order_override.rb +126 -0
  30. data/lib/switchman_inst_jobs.rb +2 -0
  31. data/lib/switchman_inst_jobs/active_record/migration.rb +10 -0
  32. data/lib/switchman_inst_jobs/delayed/backend/base.rb +29 -6
  33. data/lib/switchman_inst_jobs/engine.rb +24 -0
  34. data/lib/switchman_inst_jobs/jobs_migrator.rb +273 -0
  35. data/lib/switchman_inst_jobs/switchman/default_shard.rb +8 -0
  36. data/lib/switchman_inst_jobs/switchman/shard.rb +53 -0
  37. data/lib/switchman_inst_jobs/timed_cache.rb +19 -0
  38. data/lib/switchman_inst_jobs/version.rb +1 -1
  39. metadata +58 -15
  40. data/db/migrate/20180628153808_set_search_paths_on_functions.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4493812760b7a2e295a010eff1a90d74f606130a0ecf5bf8514435c10cda9b10
4
- data.tar.gz: 97f90c720faa8540387a3d42ddb5be0fdb92f09f66be9bdad317a2b8794d0e00
3
+ metadata.gz: 8e4c1c0421945fc0c823b2b1e452801565ac1c3e5ad9aae77d52fd8a36d83d0d
4
+ data.tar.gz: 87d5a191c8dd7c1918d1bae1d8b05ffdfee1146e462e9adab0869f2b2210f681
5
5
  SHA512:
6
- metadata.gz: 94da839955f2df3df594f5ca9b5a7ad9f55ba65cc566a036430ea2f4db5dfa313592a63e11adf2758721e930c64895856ee51acc12b9ee81f0a36a738d1ea710
7
- data.tar.gz: 24887ca2027acf074d23bc0baf07ed75ecf3a677df51213d2af01f15071461039ca101f62d3d0598e2b962d5bf081c95e1e88b91a405b3a3c11d8f44aa8d1a02
6
+ metadata.gz: a6c0abc940a6f4a7dc73923e9e020b853f23d29551bb19efa67338ae1e0da0af9065cde8f6a9f60e212f9514dd95c73b242512f1e21e53147601ff7f8cde30c1
7
+ data.tar.gz: 4caad338666dcfbb83967c007a28443a45f86aa813b8fa4f8d81f6354beb9e9f3b68ae7b4118afa5d40c6e2da77e34f7982c8e28a6c1de2e9cdcc99942acd2c4
@@ -0,0 +1,42 @@
1
+ class CreateDelayedJobs < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ unless connection.adapter_name == 'PostgreSQL'
8
+ raise("#{connection.adapter_name} is not supported for delayed jobs queue")
9
+ end
10
+
11
+ create_table :delayed_jobs do |table|
12
+ # Allows some jobs to jump to the front of the queue
13
+ table.integer :priority, default: 0
14
+ # Provides for retries, but still fail eventually.
15
+ table.integer :attempts, default: 0
16
+ # YAML-encoded string of the object that will do work
17
+ table.text :handler, limit: (500 * 1024)
18
+ # reason for last failure (See Note below)
19
+ table.text :last_error
20
+ # The queue that this job is in
21
+ table.string :queue, default: nil
22
+ # When to run.
23
+ # Could be Time.zone.now for immediately, or sometime in the future.
24
+ table.datetime :run_at
25
+ # Set when a client is working on this object
26
+ table.datetime :locked_at
27
+ # Set when all retries have failed
28
+ table.datetime :failed_at
29
+ # Who is working on this object (if locked)
30
+ table.string :locked_by
31
+
32
+ table.timestamps
33
+ end
34
+
35
+ add_index :delayed_jobs, %i[priority run_at], name: 'delayed_jobs_priority'
36
+ add_index :delayed_jobs, [:queue], name: 'delayed_jobs_queue'
37
+ end
38
+
39
+ def down
40
+ drop_table :delayed_jobs
41
+ end
42
+ end
@@ -0,0 +1,14 @@
1
+ class AddDelayedJobsTag < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ add_column :delayed_jobs, :tag, :string
8
+ add_index :delayed_jobs, [:tag]
9
+ end
10
+
11
+ def down
12
+ remove_column :delayed_jobs, :tag
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class AddDelayedJobsMaxAttempts < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ add_column :delayed_jobs, :max_attempts, :integer
8
+ end
9
+
10
+ def down
11
+ remove_column :delayed_jobs, :max_attempts
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class AddDelayedJobsStrand < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ add_column :delayed_jobs, :strand, :string
8
+ add_index :delayed_jobs, :strand
9
+ end
10
+
11
+ def down
12
+ remove_column :delayed_jobs, :strand
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ class CleanupDelayedJobsIndexes < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ case connection.adapter_name
8
+ when 'PostgreSQL'
9
+ # "nulls first" syntax is postgresql specific, and allows for more
10
+ # efficient querying for the next job
11
+ connection.execute("CREATE INDEX get_delayed_jobs_index ON #{::Delayed::Job.quoted_table_name} (priority, run_at, failed_at nulls first, locked_at nulls first, queue)")
12
+ else
13
+ add_index :delayed_jobs, %w[priority run_at locked_at failed_at queue], name: 'get_delayed_jobs_index'
14
+ end
15
+
16
+ # unused indexes
17
+ remove_index :delayed_jobs, name: 'delayed_jobs_queue'
18
+ remove_index :delayed_jobs, name: 'delayed_jobs_priority'
19
+ end
20
+
21
+ def down
22
+ remove_index :delayed_jobs, name: 'get_delayed_jobs_index'
23
+ add_index :delayed_jobs, %i[priority run_at], name: 'delayed_jobs_priority'
24
+ add_index :delayed_jobs, [:queue], name: 'delayed_jobs_queue'
25
+ end
26
+ end
@@ -0,0 +1,40 @@
1
+ class OptimizeDelayedJobs < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ create_table :failed_jobs do |t|
8
+ t.integer 'priority', default: 0
9
+ t.integer 'attempts', default: 0
10
+ t.string 'handler', limit: 512_000
11
+ t.integer 'original_id', limit: 8
12
+ t.text 'last_error'
13
+ t.string 'queue'
14
+ t.datetime 'run_at'
15
+ t.datetime 'locked_at'
16
+ t.datetime 'failed_at'
17
+ t.string 'locked_by'
18
+ t.datetime 'created_at'
19
+ t.datetime 'updated_at'
20
+ t.string 'tag'
21
+ t.integer 'max_attempts'
22
+ t.string 'strand'
23
+ end
24
+
25
+ remove_index :delayed_jobs, name: 'get_delayed_jobs_index'
26
+ remove_index :delayed_jobs, [:strand]
27
+
28
+ add_index :delayed_jobs, %w[run_at queue locked_at strand priority], name: 'index_delayed_jobs_for_get_next'
29
+ add_index :delayed_jobs, %w[strand id], name: 'index_delayed_jobs_on_strand'
30
+
31
+ # move all failed jobs to the new failed table
32
+ Delayed::Backend::ActiveRecord::Job.where('failed_at IS NOT NULL').find_each do |job|
33
+ job.fail! unless job.on_hold?
34
+ end
35
+ end
36
+
37
+ def down
38
+ raise ActiveRecord::IrreversibleMigration
39
+ end
40
+ end
@@ -0,0 +1,52 @@
1
+ class AddDelayedJobsNextInStrand < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ remove_index :delayed_jobs, name: 'index_delayed_jobs_for_get_next'
8
+
9
+ add_column :delayed_jobs, :next_in_strand, :boolean, default: true, null: false
10
+
11
+ # create the new index
12
+ connection.execute("CREATE INDEX get_delayed_jobs_index ON #{::Delayed::Job.quoted_table_name} (priority, run_at, queue) WHERE locked_at IS NULL AND next_in_strand = 't'")
13
+
14
+ # create the insert trigger
15
+ execute(<<-CODE)
16
+ CREATE FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')} () RETURNS trigger AS $$
17
+ BEGIN
18
+ LOCK delayed_jobs IN SHARE ROW EXCLUSIVE MODE;
19
+ IF (SELECT 1 FROM delayed_jobs WHERE strand = NEW.strand LIMIT 1) = 1 THEN
20
+ NEW.next_in_strand := 'f';
21
+ END IF;
22
+ RETURN NEW;
23
+ END;
24
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
25
+ CODE
26
+ execute("CREATE TRIGGER delayed_jobs_before_insert_row_tr BEFORE INSERT ON #{::Delayed::Job.quoted_table_name} FOR EACH ROW WHEN (NEW.strand IS NOT NULL) EXECUTE PROCEDURE #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')}()")
27
+
28
+ # create the delete trigger
29
+ execute(<<-CODE)
30
+ CREATE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
31
+ BEGIN
32
+ UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1);
33
+ RETURN OLD;
34
+ END;
35
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
36
+ CODE
37
+ execute("CREATE TRIGGER delayed_jobs_after_delete_row_tr AFTER DELETE ON #{::Delayed::Job.quoted_table_name} FOR EACH ROW WHEN (OLD.strand IS NOT NULL AND OLD.next_in_strand = 't') EXECUTE PROCEDURE #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} ()")
38
+
39
+ execute(%{UPDATE #{::Delayed::Job.quoted_table_name} SET next_in_strand = 'f' WHERE strand IS NOT NULL AND id <> (SELECT id FROM #{::Delayed::Job.quoted_table_name} j2 WHERE j2.strand = delayed_jobs.strand ORDER BY j2.strand, j2.id ASC LIMIT 1)})
40
+ end
41
+
42
+ def down
43
+ execute %(DROP TRIGGER delayed_jobs_before_insert_row_tr ON #{::Delayed::Job.quoted_table_name})
44
+ execute %{DROP FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')} ()}
45
+ execute %(DROP TRIGGER delayed_jobs_after_delete_row_tr ON #{::Delayed::Job.quoted_table_name})
46
+ execute %{DROP FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} ()}
47
+
48
+ remove_column :delayed_jobs, :next_in_strand
49
+ remove_index :delayed_jobs, name: 'get_delayed_jobs_index'
50
+ add_index :delayed_jobs, %w[run_at queue locked_at strand priority], name: 'index_delayed_jobs_for_get_next'
51
+ end
52
+ end
@@ -0,0 +1,31 @@
1
+ class DelayedJobsDeleteTriggerLockForUpdate < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ if connection.adapter_name == 'PostgreSQL'
8
+ execute(<<-CODE)
9
+ CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
10
+ BEGIN
11
+ UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1 FOR UPDATE);
12
+ RETURN OLD;
13
+ END;
14
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
15
+ CODE
16
+ end
17
+ end
18
+
19
+ def down
20
+ if connection.adapter_name == 'PostgreSQL'
21
+ execute(<<-CODE)
22
+ CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
23
+ BEGIN
24
+ UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1);
25
+ RETURN OLD;
26
+ END;
27
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
28
+ CODE
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ class DropPsqlJobsPopFn < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ if connection.adapter_name == 'PostgreSQL'
8
+ connection.execute('DROP FUNCTION IF EXISTS pop_from_delayed_jobs(varchar, varchar, integer, integer, timestamp without time zone)')
9
+ end
10
+ end
11
+
12
+ def down
13
+ raise ActiveRecord::IrreversibleMigration
14
+ end
15
+ end
@@ -0,0 +1,80 @@
1
+ class DelayedJobsUseAdvisoryLocks < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ # use an advisory lock based on the name of the strand, instead of locking the whole table
8
+ # note that we're using half of the md5, so collisions are possible, but we don't really
9
+ # care because that would just be the old behavior, whereas for the most part locking will
10
+ # be much smaller
11
+ if connection.adapter_name == 'PostgreSQL'
12
+ execute(<<-CODE)
13
+ CREATE FUNCTION #{connection.quote_table_name('half_md5_as_bigint')}(strand varchar) RETURNS bigint AS $$
14
+ DECLARE
15
+ strand_md5 bytea;
16
+ BEGIN
17
+ strand_md5 := decode(md5(strand), 'hex');
18
+ RETURN (CAST(get_byte(strand_md5, 0) AS bigint) << 56) +
19
+ (CAST(get_byte(strand_md5, 1) AS bigint) << 48) +
20
+ (CAST(get_byte(strand_md5, 2) AS bigint) << 40) +
21
+ (CAST(get_byte(strand_md5, 3) AS bigint) << 32) +
22
+ (CAST(get_byte(strand_md5, 4) AS bigint) << 24) +
23
+ (get_byte(strand_md5, 5) << 16) +
24
+ (get_byte(strand_md5, 6) << 8) +
25
+ get_byte(strand_md5, 7);
26
+ END;
27
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
28
+ CODE
29
+
30
+ execute(<<-CODE)
31
+ CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')} () RETURNS trigger AS $$
32
+ BEGIN
33
+ PERFORM pg_advisory_xact_lock(half_md5_as_bigint(NEW.strand));
34
+ IF (SELECT 1 FROM delayed_jobs WHERE strand = NEW.strand LIMIT 1) = 1 THEN
35
+ NEW.next_in_strand := 'f';
36
+ END IF;
37
+ RETURN NEW;
38
+ END;
39
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
40
+ CODE
41
+
42
+ execute(<<-CODE)
43
+ CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
44
+ BEGIN
45
+ PERFORM pg_advisory_xact_lock(half_md5_as_bigint(OLD.strand));
46
+ UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1 FOR UPDATE);
47
+ RETURN OLD;
48
+ END;
49
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
50
+ CODE
51
+ end
52
+ end
53
+
54
+ def down
55
+ if connection.adapter_name == 'PostgreSQL'
56
+ execute(<<-CODE)
57
+ CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_before_insert_row_tr_fn')} () RETURNS trigger AS $$
58
+ BEGIN
59
+ LOCK delayed_jobs IN SHARE ROW EXCLUSIVE MODE;
60
+ IF (SELECT 1 FROM delayed_jobs WHERE strand = NEW.strand LIMIT 1) = 1 THEN
61
+ NEW.next_in_strand := 'f';
62
+ END IF;
63
+ RETURN NEW;
64
+ END;
65
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
66
+ CODE
67
+
68
+ execute(<<-CODE)
69
+ CREATE OR REPLACE FUNCTION #{connection.quote_table_name('delayed_jobs_after_delete_row_tr_fn')} () RETURNS trigger AS $$
70
+ BEGIN
71
+ UPDATE delayed_jobs SET next_in_strand = 't' WHERE id = (SELECT id FROM delayed_jobs j2 WHERE j2.strand = OLD.strand ORDER BY j2.strand, j2.id ASC LIMIT 1 FOR UPDATE);
72
+ RETURN OLD;
73
+ END;
74
+ $$ LANGUAGE plpgsql SET search_path TO #{::Switchman::Shard.current.name};
75
+ CODE
76
+
77
+ execute("DROP FUNCTION #{connection.quote_table_name('half_md5_as_bigint')}(varchar)")
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,15 @@
1
+ class IndexJobsOnLockedBy < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction! if respond_to?(:disable_ddl_transaction!)
3
+
4
+ def connection
5
+ Delayed::Backend::ActiveRecord::Job.connection
6
+ end
7
+
8
+ def up
9
+ add_index :delayed_jobs, :locked_by, algorithm: :concurrently, where: 'locked_by IS NOT NULL'
10
+ end
11
+
12
+ def down
13
+ remove_index :delayed_jobs, :locked_by
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class AddJobsRunAtIndex < ActiveRecord::Migration[4.2]
2
+ disable_ddl_transaction! if respond_to?(:disable_ddl_transaction!)
3
+
4
+ def connection
5
+ Delayed::Backend::ActiveRecord::Job.connection
6
+ end
7
+
8
+ def up
9
+ add_index :delayed_jobs, %w[run_at tag], algorithm: :concurrently
10
+ end
11
+
12
+ def down
13
+ remove_index :delayed_jobs, name: 'index_delayed_jobs_on_run_at_and_tag'
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class ChangeDelayedJobsHandlerToText < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Job.connection
4
+ end
5
+
6
+ def up
7
+ change_column :delayed_jobs, :handler, :text
8
+ end
9
+
10
+ def down
11
+ change_column :delayed_jobs, :handler, :string, limit: 500.kilobytes
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddFailedJobsOriginalJobId < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ add_column :failed_jobs, :original_job_id, :integer, limit: 8
8
+ end
9
+
10
+ def down
11
+ remove_column :failed_jobs, :original_job_id
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ class CopyFailedJobsOriginalId < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ # this is a smaller, less frequently accessed table, so we just update all at once
8
+ Delayed::Backend::ActiveRecord::Job::Failed.where('original_job_id is null').update_all('original_job_id = original_id')
9
+ end
10
+
11
+ def down; end
12
+ end
@@ -0,0 +1,13 @@
1
+ class DropFailedJobsOriginalId < ActiveRecord::Migration[4.2]
2
+ def connection
3
+ Delayed::Backend::ActiveRecord::Job.connection
4
+ end
5
+
6
+ def up
7
+ remove_column :failed_jobs, :original_id
8
+ end
9
+
10
+ def down
11
+ add_column :failed_jobs, :original_id, :integer, limit: 8
12
+ end
13
+ end