# frozen_string_literal: true

class CreateUxToolkitRecurringIssueRules < ActiveRecord::Migration[6.1]
  def change
    create_table :ux_toolkit_recurring_issue_rules do |t|
      t.boolean :enabled, null: false, default: true
      t.integer :project_id, null: false
      t.integer :tracker_id, null: false
      t.string :subject, null: false
      t.text :description
      t.integer :priority_id, null: false
      t.integer :assigned_to_id
      t.integer :category_id
      t.string :interval, null: false
      t.date :next_run_on, null: false
      t.date :last_run_on
      t.string :last_status
      t.text :last_message
      t.datetime :locked_until
      t.integer :created_by_id
      t.integer :updated_by_id
      t.timestamps
    end

    add_index :ux_toolkit_recurring_issue_rules, :enabled
    add_index :ux_toolkit_recurring_issue_rules, :project_id
    add_index :ux_toolkit_recurring_issue_rules, :tracker_id
    add_index :ux_toolkit_recurring_issue_rules, :next_run_on
    add_index :ux_toolkit_recurring_issue_rules, :locked_until
  end
end
