Change state to integer for issuables - Release 2 of 2

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 11.10: 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 11.12: This issue

  1. Adds new indexes to state_id column

  2. Add the code which uses the new state_id column

  3. Removes old state column with a post deployment migration

Edited by Felipe Cardozo