Fix migration with fkeys

Creation of fkeys doesn't work in sqlite, so we should do these
changes in another dialects.
Fix bug 1204823.

Also we can have a problem with data conflicted with declared ForeignKey.
We should dump "bad" data to another place, upgrade and create FK.
Downgrade method should restore dumped data.

Change-Id: I33089d6f47dcde4cf716a3d303c8df23dd19cd07
Merge "Fix migration with fkeys"