Permalink
Browse files

delayed_job gem and table

  • Loading branch information...
1 parent cd4fb50 commit d0b3a37aa4054232f9059417de63ea3be7913026 @cocoa committed Nov 3, 2012
Showing with 51 additions and 1 deletion.
  1. +1 −0 Gemfile
  2. +6 −0 Gemfile.lock
  3. +22 −0 db/migrate/20121103205829_create_delayed_jobs.rb
  4. +17 −1 db/schema.rb
  5. +5 −0 script/delayed_job
View
@@ -8,6 +8,7 @@ gem 'rails', '3.2.8'
gem 'sqlite3'
gem 'feedzirra'
gem 'feedbag'
+gem 'delayed_job_active_record'
# Gems used only for assets and not required
View
@@ -38,6 +38,11 @@ GEM
execjs
coffee-script-source (1.4.0)
curb (0.8.1)
+ delayed_job (3.0.2)
+ activesupport (~> 3.0)
+ delayed_job_active_record (0.3.2)
+ activerecord (> 2.1.0)
+ delayed_job (~> 3.0.0)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
@@ -118,6 +123,7 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
+ delayed_job_active_record
feedbag
feedzirra
jquery-rails
@@ -0,0 +1,22 @@
+class CreateDelayedJobs < ActiveRecord::Migration
+ def self.up
+ create_table :delayed_jobs, :force => true do |table|
+ table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
+ table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
+ table.text :handler # YAML-encoded string of the object that will do work
+ table.text :last_error # reason for last failure (See Note below)
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
+ table.datetime :locked_at # Set when a client is working on this object
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
+ table.string :locked_by # Who is working on this object (if locked)
+ table.string :queue # The name of the queue this job is in
+ table.timestamps
+ end
+
+ add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
+ end
+
+ def self.down
+ drop_table :delayed_jobs
+ end
+end
View
@@ -11,7 +11,23 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121102205938) do
+ActiveRecord::Schema.define(:version => 20121103205829) do
+
+ create_table "delayed_jobs", :force => true do |t|
+ t.integer "priority", :default => 0
+ t.integer "attempts", :default => 0
+ t.text "handler"
+ t.text "last_error"
+ t.datetime "run_at"
+ t.datetime "locked_at"
+ t.datetime "failed_at"
+ t.string "locked_by"
+ t.string "queue"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
+ add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
create_table "feeds", :force => true do |t|
t.string "title", :default => "(pending)"
View
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
+require 'delayed/command'
+Delayed::Command.new(ARGV).daemonize

0 comments on commit d0b3a37

Please sign in to comment.