class CreateInitialModels

Public Instance Methods

change() click to toggle source
# 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