private function shouldExecuteMigration($direction, Version $version, $to, $migrated)
    {
        if ('down' === $direction) {
            if (!in_array($version->getVersion(), $migrated)) {
                return false;
            }

            return $version->getVersion() > $to;
        }

        if ('up' === $direction) {
            if (in_array($version->getVersion(), $migrated)) {
                return false;
            }

            return $version->getVersion() <= $to;
        }
    }