Specify index structure in the model definitions

We specify indexes in the model definitions, so the database structure is spelled out more or less in one place.

Update the ensureStructure.js script to take advantage of the changes and to rely on Mongoose in general.

/cc @hampelm