def data_migrate(db: DB, from_version: Optional[str]):
    """Makes any data changes needed for upgrading from the from_version to the
    current version.

    Args:
        db: The database instance.

        from_version: The version to migrate data from.

    Raises:
        VersionException: Can raise a migration or validation upgrade error.
    """

    if from_version is None:
        sql_alchemy_from_version = 1
    else:
        sql_alchemy_from_version = int(from_version)
    from_compat_version = _get_sql_alchemy_compatibility_version(
        sql_alchemy_from_version
    )
    to_compat_version = None
    fail_advice = "Please open a ticket on trulens github page including this error message. The migration completed so you can still proceed; but stability is not guaranteed. If needed, you can `TruSession.reset_database()`"

    try:
        while from_compat_version in sqlalchemy_upgrade_paths:
            to_compat_version, migrate_fn = sqlalchemy_upgrade_paths[
                from_compat_version
            ]
            migrate_fn(db)
            from_compat_version = to_compat_version
        print("DB Migration complete!")
    except Exception as e:
        tb = traceback.format_exc()
        current_revision = db_migrations.DbRevisions.load(db.engine).current
        raise legacy_migration.VersionException(
            f"Migration failed on {db} from db version - {from_version} on step: {str(to_compat_version)}. The attempted DB version is {current_revision} \n\n{tb}\n\n{fail_advice}"
        ) from e
    try:
        _sql_alchemy_serialization_asserts(db)
        print("DB Validation complete!")
    except Exception as e:
        tb = traceback.format_exc()
        current_revision = db_migrations.DbRevisions.load(db.engine).current
        raise legacy_migration.VersionException(
            f"Validation failed on {db} from db version - {from_version} on step: {str(to_compat_version)}. The attempted DB version is {current_revision} \n\n{tb}\n\n{fail_advice}"
        ) from e
Makes any data changes needed for upgrading from the from_version to the
    current version.

    Args:
        db: The database instance.

        from_version: The version to migrate data from.

    Raises:
        VersionException: Can raise a migration or validation upgrade error.
    
src/core/trulens/core/database/migrations/data.py