Parity with upstream project, add missing active record adapter file.
Add support for db migrate.
Minor restructuring of the code.