(refactor) SQL migration, some testing still in progress