Uses session in migration to stop DB locking

Using both the engine and session in a migration causes the DB to
become locked.

Change-Id: Icbd867ff4e385f4430bfa9b7c5680b870475176d
Closes-bug: #1371620
Merge "Uses session in migration to stop DB locking"