Adding alembic migration and fixing SQL errors.