good_job 1.99.0 → 1.99.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2808 -8
- data/README.md +13 -0
- data/lib/generators/good_job/install_generator.rb +6 -6
- data/lib/generators/good_job/templates/update/migrations/03_add_active_job_id_index_and_concurrency_key_index_to_good_jobs.rb +3 -0
- data/lib/generators/good_job/update_generator.rb +4 -6
- data/lib/good_job/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -86,6 +86,13 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
86
86
|
$ bin/rails db:migrate
|
87
87
|
```
|
88
88
|
|
89
|
+
Optional: If using Rails' multiple databases with the `migrations_paths` configuration option, use the `--database` option:
|
90
|
+
|
91
|
+
```bash
|
92
|
+
bin/rails g good_job:install --database animals
|
93
|
+
bin/rails db:migrate:animals
|
94
|
+
```
|
95
|
+
|
89
96
|
1. Configure the ActiveJob adapter:
|
90
97
|
|
91
98
|
```ruby
|
@@ -419,6 +426,12 @@ To perform upgrades to the GoodJob database tables:
|
|
419
426
|
bin/rails g good_job:update
|
420
427
|
```
|
421
428
|
|
429
|
+
Optional: If using Rails' multiple databases with the `migrations_paths` configuration option, use the `--database` option:
|
430
|
+
|
431
|
+
```bash
|
432
|
+
$ bin/rails g good_job:update --database animals
|
433
|
+
```
|
434
|
+
|
422
435
|
1. Run the database migration locally
|
423
436
|
|
424
437
|
```bash
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'rails/generators'
|
3
3
|
require 'rails/generators/active_record'
|
4
|
+
|
4
5
|
module GoodJob
|
5
6
|
#
|
6
7
|
# Rails generator used for setting up GoodJob in a Rails application.
|
7
8
|
# Run it with +bin/rails g good_job:install+ in your console.
|
8
9
|
#
|
9
10
|
class InstallGenerator < Rails::Generators::Base
|
10
|
-
include
|
11
|
+
include ActiveRecord::Generators::Migration
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
13
|
+
TEMPLATES = File.join(File.dirname(__FILE__), "templates/install")
|
14
|
+
source_paths << TEMPLATES
|
15
15
|
|
16
|
-
|
16
|
+
class_option :database, type: :string, aliases: %i(--db), desc: "The database for your migration. By default, the current environment's primary database is used."
|
17
17
|
|
18
18
|
# Generates monolithic migration file that contains all database changes.
|
19
19
|
def create_migration_file
|
20
|
-
migration_template 'migrations/create_good_jobs.rb.erb',
|
20
|
+
migration_template 'migrations/create_good_jobs.rb.erb', File.join(db_migrate_path, "create_good_jobs.rb")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -21,8 +21,11 @@ class AddActiveJobIdIndexAndConcurrencyKeyIndexToGoodJobs < ActiveRecord::Migrat
|
|
21
21
|
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", algorithm: :concurrently, name: :index_good_jobs_on_concurrency_key_when_unfinished
|
22
22
|
add_index :good_jobs, [:cron_key, :created_at], algorithm: :concurrently, name: :index_good_jobs_on_cron_key_and_created_at
|
23
23
|
|
24
|
+
return unless defined? GoodJob::Job
|
25
|
+
|
24
26
|
reversible do |dir|
|
25
27
|
dir.up do
|
28
|
+
# Ensure that all `good_jobs` records have an active_job_id value
|
26
29
|
start_time = Time.current
|
27
30
|
loop do
|
28
31
|
break if GoodJobJobs.where(active_job_id: nil, finished_at: nil).where("created_at < ?", start_time).limit(UPDATE_BATCH_SIZE).update_all("active_job_id = (serialized_params->>'job_id')::uuid").zero?
|
@@ -8,22 +8,20 @@ module GoodJob
|
|
8
8
|
# Run it with +bin/rails g good_job:update+ in your console.
|
9
9
|
#
|
10
10
|
class UpdateGenerator < Rails::Generators::Base
|
11
|
-
include
|
12
|
-
|
13
|
-
class << self
|
14
|
-
delegate :next_migration_number, to: ActiveRecord::Generators::Base
|
15
|
-
end
|
11
|
+
include ActiveRecord::Generators::Migration
|
16
12
|
|
17
13
|
TEMPLATES = File.join(File.dirname(__FILE__), "templates/update")
|
18
14
|
source_paths << TEMPLATES
|
19
15
|
|
16
|
+
class_option :database, type: :string, aliases: %i(--db), desc: "The database for your migration. By default, the current environment's primary database is used."
|
17
|
+
|
20
18
|
# Generates incremental migration files unless they already exist.
|
21
19
|
# All migrations should be idempotent e.g. +add_index+ is guarded with +if_index_exists?+
|
22
20
|
def update_migration_files
|
23
21
|
migration_templates = Dir.children(File.join(TEMPLATES, 'migrations')).sort
|
24
22
|
migration_templates.each do |template_file|
|
25
23
|
destination_file = template_file.match(/^\d*_(.*\.rb)/)[1] # 01_create_good_jobs.rb.erb => create_good_jobs.rb
|
26
|
-
migration_template "migrations/#{template_file}",
|
24
|
+
migration_template "migrations/#{template_file}", File.join(db_migrate_path, destination_file), skip: true
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
data/lib/good_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: good_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.99.
|
4
|
+
version: 1.99.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -428,7 +428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
428
428
|
- !ruby/object:Gem::Version
|
429
429
|
version: '0'
|
430
430
|
requirements: []
|
431
|
-
rubygems_version: 3.
|
431
|
+
rubygems_version: 3.1.6
|
432
432
|
signing_key:
|
433
433
|
specification_version: 4
|
434
434
|
summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
|