Change state to integer for issuables - Release 2 of 3

This issue covers the second release in the process of moving issuable states to integer. After the new column
state_id has been added on the first release we now need to move forward with the following tasks to complete the migration:

  1. Add new indexes to state_id column
  2. Add model code that uses state_id column instead of state
  3. Removes old state column with a post deployment migration

Schedule

First release: https://gitlab.com/gitlab-org/gitlab-ce/issues/51789

  1. Add a state_id column to issues and merge requests tables

  2. Schedule a background migration that will populate state_id column with new values

Second release: This issue

  1. Adds new indexes to state_id column

  2. Add the code which uses the new state_id column

Third release: #33814 (closed)

  1. Removes old state column
Edited by Felipe Cardozo