class Create<%= class_name.pluralize %> < ActiveRecord::Migration
  def change
    create_table :<%= file_name.pluralize %> do |t|
      t.belongs_to :workflow_instance, index: true
      t.string :state
      t.string :sti_type
      t.text :notes

      <%- attributes.each do |attribute| -%>
        <%- if attribute.boolean? -%>
      t.boolean :<%= attribute.name %>, default: false, null: false
        <%- else -%>
      t.<%= attribute.type %> :<%= attribute.name %>
        <%- end -%>
      <%- end -%>

      t.timestamps null: false
    end

    <%- scenarios.map(&:classify).each do |scenario| -%>
    WorkflowInstance::<%= scenario %>.pluck(:id).each{|id| <%= class_name %>::<%= scenario %>.create!(workflow_instance_id: id) }
    <%- end -%>
  end
end
