public function getMigrationSql($version, $increment)
    {
        // I could use the GLOB_BRACE but it is not supported on ALPINE distros.
        // So, I have to call multiple times to simulate the braces.

        if (intval($version) != $version) {
            throw new \InvalidArgumentException("Version '$version' should be a integer number");
        }
        $version = intval($version);

        $filePattern = $this->folder
            . "/migrations"
            . "/" . ($increment < 0 ? "down" : "up")
            . "/*.sql";

        $result = array_filter(glob($filePattern), function ($file) use ($version) {
            return preg_match("/^0*$version(-dev)?\.sql$/", basename($file));
        });

        // Valid values are 0 or 1
        if (count($result) > 1) {
            throw new InvalidMigrationFile("You have two files with the same version number '$version'");
        }

        foreach ($result as $file) {
            if (intval(basename($file)) === $version) {
                return $file;
            }
        }
        return null;
    }
public function getMigrationSql($version, $increment)
    {
        // I could use the GLOB_BRACE but it is not supported on ALPINE distros.
        // So, I have to call multiple times to simulate the braces.

        if (intval($version) != $version) {
            throw new \InvalidArgumentException("Version '$version' should be a integer number");
        }
        $version = intval($version);

        $filePattern = $this->folder
            . "/migrations"
            . "/" . ($increment < 0 ? "down" : "up")
            . "/*.sql";

        $result = array_filter(glob($filePattern), function ($file) use ($version) {
            return preg_match("/^0*$version(-dev)?\.sql$/", basename($file));
        });

        // Valid values are 0 or 1
        if (count($result) > 1) {
            throw new InvalidMigrationFile("You have two files with the same version number '$version'");
        }

        foreach ($result as $file) {
            if (intval(basename($file)) === $version) {
                return $file;
            }
        }
        return null;
    }
public function getMigrationSql ( $ version , $ increment ) { // I could use the GLOB_BRACE but it is not supported on ALPINE distros. // So, I have to call multiple times to simulate the braces. if ( intval ( $ version ) != $ version ) { throw new \ InvalidArgumentException ( "Version '$version' should be a integer number" ) ; } $ version = intval ( $ version ) ; $ filePattern = $ this -> folder . "/migrations" . "/" . ( $ increment < 0 ? "down" : "up" ) . "/*.sql" ; $ result = array_filter ( glob ( $ filePattern ) , function ( $ file ) use ( $ version ) { return preg_match ( "/^0*$version(-dev)?\.sql$/" , basename ( $ file ) ) ; } ) ; // Valid values are 0 or 1 if ( count ( $ result ) > 1 ) { throw new InvalidMigrationFile ( "You have two files with the same version number '$version'" ) ; } foreach ( $ result as $ file ) { if ( intval ( basename ( $ file ) ) === $ version ) { return $ file ; } } return null ; }
Get the full path script based on the version

@param $version
@param $increment
@return string
@throws \ByJG\DbMigration\Exception\InvalidMigrationFile
Get the full path script based on the version