Add create_large_indexes management command.
Add create_large_indexes management command.

This management command creates the same indexes as migrations
82, 83, and 95, which are all indexes on the huge UserMessage
table. (*)

This command quickly no-ops with clear messaging when the
indexes already exist, so it's idempotent in that regard. (If
somebody somehow creates an index by the same name incorrectly,
they can always drop it in dbshell and re-run this command.)

If any of the migrations have not been run, which we detect simply
by the existence of the indexes, then we create them using a
`CREATE INDEX CONCURRENTLY` command.  This functionality in
postgres allows you to create indexes against large tables
without disrupting queries against those tables.  The tradeoff
here is that creating indexes concurrently takes significantly
longer than doing them non-concurrently.

Since most tables are small, we typically just use regular
Django migrations and run them during a brief interval while
the app is down.

For indexes on big tables, we will want to run this command
as part of the upgrade process, and we will want to run
it while the app is still up, otherwise it's pointless.

All the code in create_indexes() is literally copy/pasted
from the relevant migrations, and that scheme should work
going forward.  (It uses a different implementation of
create_index_if_not_exist than the migrations use, but the
code is identical lexically in the function.)

If we ever do major restructuring of our large tables, such
as UserMessage, and we end up droppping some of these indexes,
then we will need to make this command migrations-aware.  For
now it's safe to assume that indexes are generally additive in
nature, and the sooner we create them during the upgrade process,
the better.

(*) UserMessage is huge for large installations, of course.

shubhamdhama/zulip,dhcrzf/zulip,amanharitsh123/zulip,timabbott/zulip,mahim97/zulip,synicalsyntax/zulip,eeshangarg/zulip,timabbott/zulip,timabbott/zulip,kou/zulip,rht/zulip,rishig/zulip,synicalsyntax/zulip,rht/zulip,punchagan/zulip,amanharitsh123/zulip,andersk/zulip,timabbott/zulip,Galexrt/zulip,tommyip/zulip,zulip/zulip,synicalsyntax/zulip,Galexrt/zulip,rishig/zulip,zulip/zulip,synicalsyntax/zulip,synicalsyntax/zulip,rht/zulip,kou/zulip,brockwhittaker/zulip,punchagan/zulip,dhcrzf/zulip,brockwhittaker/zulip,tommyip/zulip,brockwhittaker/zulip,zulip/zulip,synicalsyntax/zulip,eeshangarg/zulip,showell/zulip,shubhamdhama/zulip,andersk/zulip,kou/zulip,punchagan/zulip,showell/zulip,timabbott/zulip,kou/zulip,shubhamdhama/zulip,tommyip/zulip,eeshangarg/zulip,jackrzhang/zulip,jackrzhang/zulip,showell/zulip,eeshangarg/zulip,brockwhittaker/zulip,andersk/zulip,punchagan/zulip,kou/zulip,hackerkid/zulip,brainwane/zulip,kou/zulip,rishig/zulip,rht/zulip,mahim97/zulip,hackerkid/zulip,vaidap/zulip,brainwane/zulip,dhcrzf/zulip,Galexrt/zulip,andersk/zulip,rishig/zulip,amanharitsh123/zulip,mahim97/zulip,amanharitsh123/zulip,rht/zulip,verma-varsha/zulip,hackerkid/zulip,timabbott/zulip,tommyip/zulip,zulip/zulip,vaidap/zulip,showell/zulip,showell/zulip,zulip/zulip,showell/zulip,rht/zulip,brainwane/zulip,dhcrzf/zulip,punchagan/zulip,brockwhittaker/zulip,jackrzhang/zulip,hackerkid/zulip,mahim97/zulip,jackrzhang/zulip,andersk/zulip,synicalsyntax/zulip,timabbott/zulip,kou/zulip,brainwane/zulip,rishig/zulip,tommyip/zulip,jackrzhang/zulip,punchagan/zulip,mahim97/zulip,vaidap/zulip,hackerkid/zulip,dhcrzf/zulip,vaidap/zulip,shubhamdhama/zulip,mahim97/zulip,Galexrt/zulip,rht/zulip,andersk/zulip,eeshangarg/zulip,Galexrt/zulip,verma-varsha/zulip,zulip/zulip,brainwane/zulip,eeshangarg/zulip,hackerkid/zulip,shubhamdhama/zulip,brainwane/zulip,verma-varsha/zulip,Galexrt/zulip,tommyip/zulip,andersk/zulip,punchagan/zulip,shubhamdhama/zulip,verma-varsha/zulip,zulip/zulip,vaidap/zulip,verma-varsha/zulip,jackrzhang/zulip,rishig/zulip,dhcrzf/zulip,Galexrt/zulip,brainwane/zulip,verma-varsha/zulip,jackrzhang/zulip,showell/zulip,tommyip/zulip,brockwhittaker/zulip,rishig/zulip,amanharitsh123/zulip,hackerkid/zulip,dhcrzf/zulip,shubhamdhama/zulip,eeshangarg/zulip,vaidap/zulip,amanharitsh123/zulip