-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8a31c8
commit cf24701
Showing
5 changed files
with
43 additions
and
1 deletion.
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
Binary file added
BIN
+12 KB
generators/delayed_job_migration/.delayed_job_migration_generator.rb.swp
Binary file not shown.
15 changes: 15 additions & 0 deletions
15
generators/delayed_job_migration/delayed_job_migration_generator.rb
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,15 @@ | ||
class DelayedJobMigrationGenerator < Rails::Generator::Base | ||
def manifest | ||
record do |m| | ||
options = { | ||
:migration_file_name => 'create_delayed_jobs' | ||
} | ||
|
||
m.migration_template 'migration.rb', 'db/migrate', options | ||
end | ||
end | ||
|
||
def banner | ||
"Usage: #{$0} #{spec.name}" | ||
end | ||
end |
Binary file not shown.
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,22 @@ | ||
class CreateDelayedJobs < ActiveRecord::Migration | ||
def self.up | ||
create_table :delayed_jobs, :force => true do |t| | ||
t.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue | ||
t.integer :attempts, :default => 0 # Provides for retries, but still fail eventually. | ||
t.text :handler # YAML-encoded string of the object that will do work | ||
t.string :last_error # reason for last failure (See Note below) | ||
t.datetime :run_at # When to run. Could be Time.now for immediately, or sometime in the future. | ||
t.datetime :locked_at # Set when a client is working on this object | ||
t.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) | ||
t.string :locked_by # Who is working on this object (if locked) | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :delayed_jobs, :locked_by | ||
end | ||
|
||
def self.down | ||
drop_table :delayed_jobs | ||
end | ||
end |