# frozen_string_literal: true

class CreateUxToolkitRecentProjects < ActiveRecord::Migration[6.1]
  def change
    create_table :ux_toolkit_recent_projects do |t|
      t.integer :user_id, null: false
      t.integer :project_id, null: false
      t.datetime :last_visited_at, null: false
      t.timestamps
    end

    add_index :ux_toolkit_recent_projects,
              [:user_id, :project_id],
              unique: true,
              name: 'idx_ux_toolkit_recent_projects_user_project'
    add_index :ux_toolkit_recent_projects, :user_id
    add_index :ux_toolkit_recent_projects, :project_id
    add_index :ux_toolkit_recent_projects, :last_visited_at
  end
end
