Class: CreateInitialModels

Inherits:
Object
  • Object
show all
Defined in:
lib/qyu/store/activerecord/db/migrate/20170529131352_create_initial_models.rb

Instance Method Summary collapse

Instance Method Details

#changeObject



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
# File 'lib/qyu/store/activerecord/db/migrate/20170529131352_create_initial_models.rb', line 4

def change
  create_table :workflows do |t|
    t.string :name, null: false, unique: true
    t.jsonb :descriptor, null: false
  end

  add_index :workflows, :name, unique: true, name: 'workflows_name_unique_index'

  create_table :jobs do |t|
    t.jsonb :payload

    t.references :workflow, foreign_key: true

    t.timestamps
  end

  create_table :tasks do |t|
    t.string :name
    t.string :queue_name
    t.string :status
    t.column :locked_until, 'timestamp with time zone'
    t.string :locked_by
    t.jsonb :payload

    t.references :job, foreign_key: true
    t.references :parent_task, table_name: 'tasks', foreign_key: { to_table: 'tasks' }

    t.timestamps
  end
end