class CreateIssueWorkflowStates < ActiveRecord::Migration[6.1] def change create_table :issue_workflow_states do |t| t.integer :issue_id, null: false t.bigint :custom_workflow_id, null: false t.bigint :current_step_id t.integer :completed_by_id t.datetime :started_at t.datetime :completed_at t.timestamps end add_index :issue_workflow_states, :issue_id, unique: true add_index :issue_workflow_states, :custom_workflow_id add_index :issue_workflow_states, :current_step_id add_foreign_key :issue_workflow_states, :issues add_foreign_key :issue_workflow_states, :custom_workflows add_foreign_key :issue_workflow_states, :workflow_steps, column: :current_step_id end end