moneyadviceservice/frontend — pull request #695 by munckymagik (2014-09-25 14:19:27+00:00)
Title: Transfer initial tables to a migration so that all migrations can run

Fixes a problem where migrations from engines are not run after a
db:schema:load, or the schema.rb loses the initial tables when
running db:migrate.

All of the base tables were defined only in the schema.rb and the version
timestamp was newer than the timestamps in the migrations in the mounted
engines.

Schema load assumes that schema.rb includes all migrations earlier than
the schema version (timestamp), and populates the schema_migration table
to reflect this.

The solution here is to pull all of the tables in schema.rb out into a
migration with a version timestamp earlier than the migrations in all
currently attached engines. Having done this:

* rake db:migrate and db:schema:load are be equivalent assuming no new migrations are pending
* Migrations are consistently the one way to add any schema definitions to the database

## Alternative Solutions We Considered

One other solution we considered was to simply take the `version` out of schema.rb.

Pros:
* Smallest change to fix
* rake db:migrate would now work after a db:schema:load

Cons:
* rake db:schema:load would only load the locally defined initial tables and none of those required by the engines
* rake db:migrate would overwrite schema.rb after every migration and developers would need to remember to revert it and not accidentally commit it.
* Having some tables in migrations and others only in schema.rb seems inconsistent and makes it confusing to work out what the correct work flow is for initialising the database.