explicitly index map tables' first columns

In old databases, the various association tables will have an index on
their first column. It is a left-over implicit index created by MySQL
because they had no primary key. In newly created databases this is
absent because MySQL uses the PK instead of an implicit index.

This is a side-effect of commit ca7c56e6 for bug 642834.

We can just make the indexes explicit, and add them on newer databases
where they are not already present, because why not.

Change-Id: Ib7794141b94fadcdbfa4844a2f4c280bf8f2f272
fix NULLability on a number of old columns

Change-Id: I5762fa7d4165dcd132ede32afbbb0bb9474477a5
index recipe.start_time

We have this index in our production database. I can't figure out why.
But it seems quite useful, since we reference the recipe.start_time
column in a number of queries.

Change-Id: Ib5ea0f491f21d4e6c87d04df545f9dd615421b04
add missing foreign key constraints

These foreign key constraints may be missing in very old databases.
I believe these all date back to the time when Beaker was accidentally
creating new tables in MyISAM instead of InnoDB, and so MySQL was
silently discarding foreign key constraints we had defined.

Change-Id: I6d12f0f06144fcb0d11b0ab9df125e35639f8cdf
explicitly index osversion.osmajor_id

As of commit a1260a5a this table has a unique constraint covering
osmajor_id, which means MySQL doesn't implicitly create an index for
that column. However older database schemas will have the implicit index
left over. We might as well add it explicitly.

This is similar to commit cefa9e0a.

Change-Id: I758d290337249c39f0767c7b9da0bad2c9c3050c
system_activity.system_id should not be NULLable

This was a typo in commit d8cbbb0a2 for bug 654304.

Change-Id: Ia52a25d162bac193a275d67bce0b24748d55d1a3
fix wrong type of job.product_id column

Bug: 1061955
Change-Id: Iec7e2706f98815c9760edf127d80c2b5e6a56196
drop some duplicate indexes on job and recipe_set

These exist in our production database, but I have no idea why. Most
likely some old upgrade instructions that went a bit awry.

Change-Id: I5528e0f593f50624fea0320494c46afacb5c4d24
add missing unique constraint on beaker_tag

This was an oversight in commit 1b96af86 for bug 691745.

Change-Id: Ic44e777aaa153b0ad86f2e305d380c271a6ad20b
device_class_id should be included in device unique constraint

This was a typo in commit e419b4e0 for bug 816553.

Change-Id: I5c04050a9e35947d62ea11d577e842ebbf0a9bc4
fix type of task.owner column in old databases

This was a mistake in the 0.7.1 upgrade notes, added in commit d63ca585
for bug 617274.

Change-Id: Ibf0a59d86b7d3c3fe9b76f485465e4db2c317cbf
remove database-side defaults

See the bug report for complete discussion/rationale.

Some other previous database-side defaults are removed as a side effect
of the upgrades in commit 5cf89f53.

Bug: 1069438
Change-Id: Ic26ec9bbbb848cb5917a36115fb2a847c73c7121
also test migration on real production schemas

These tests shook out a lot of bugs in older upgrades, which are
fixed/worked around by prior patches in the series leading up to this
one.

Change-Id: Iae7eeb7aa76ddb13ce9d1d1898a450dcf2a34b64