public
Description: Database based asynchronously priority queue system -- Extracted from Shopify
Homepage: http://www.shopify.com
Clone URL: git://github.com/tobi/delayed_job.git
Search Repo:
delayed_job / spec / database.rb
100644 35 lines (28 sloc) 1.041 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
$:.unshift(File.dirname(__FILE__) + '/../lib')
                                     
require 'rubygems'
require 'active_record'
require File.dirname(__FILE__) + '/../init'
 
ActiveRecord::Base.logger = Logger.new(nil)
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => '/tmp/jobs.sqlite')
ActiveRecord::Migration.verbose = false
          
def reset_db
  ActiveRecord::Schema.define do
 
    create_table :delayed_jobs, :force => true do |table|
      table.integer :priority, :default => 0
      table.integer :attempts, :default => 0
      table.text :handler
      table.string :last_error
      table.datetime :run_at
      table.datetime :locked_at
      table.string :locked_by
      table.timestamps
    end
 
    create_table :stories, :force => true do |table|
      table.string :text
    end
 
  end
end
    
# Purely useful for test cases...
class Story < ActiveRecord::Base
  def tell; text; end
end