Class: CreateDuctworkProcesses

Inherits:
Ductwork::Migration show all
Defined in:
lib/generators/ductwork/install/templates/db/create_ductwork_processes.rb

Instance Method Summary collapse

Methods included from Ductwork::MigrationHelper

#belongs_to, #create_ductwork_table, #mysql?, #postgresql?, #uuid_column_type

Instance Method Details

#changeObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/ductwork/install/templates/db/create_ductwork_processes.rb', line 4

def change
  create_ductwork_table :ductwork_processes do |table|
    table.integer :pid, null: false
    table.string :machine_identifier, null: false
    table.string :role, null: false
    table.timestamp :last_heartbeat_at, null: false
    table.timestamps null: false
  end

  add_index :ductwork_processes, :last_heartbeat_at
  add_index :ductwork_processes, %i[pid machine_identifier], unique: true
end