src/RocknRoot/StrayFw/Database/Migration.php
public function generate(Request $req)
    {
        if (count($req->getArgs()) != 2) {
            echo 'Wrong arguments.' . PHP_EOL . 'Usage : db/migration/create mapping_name migration_name' . PHP_EOL;
        } else {
            $mappingName = $req->getArgs()[0];
            $mapping = Mapping::get($mappingName);
            $name = ucfirst($req->getArgs()[1]);
            $path = rtrim($mapping['config']['migrations']['path'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            $path .= $name . DIRECTORY_SEPARATOR . $name . '.php';
            if (file_exists($path) === false) {
                throw new FileNotReadable('can\'t find migration at "' . $path . '"');
            }
            $cl = '\\' . ltrim(rtrim($mapping['config']['provider'], '\\'), '\\') . '\\Migration::generate';
            if (is_callable($cl) === false) {
                throw new RuntimeException(
                    'Migration generate method is not callable on configured provider!'
                );
            }
            $res = call_user_func($cl, $mapping, $mappingName, $name);
            $this->write($mapping, $mappingName, $name, $res['up'], $res['down'], $res['import']);
            echo 'Migration "' . $name . '" generated.' . PHP_EOL;
            echo 'This is an automatic generation, please validate or rewrite parts of the migration.' . PHP_EOL;
            echo 'File is there:' . PHP_EOL;
            echo $path . PHP_EOL;
        }
    }
public function generate(Request $req)
    {
        if (count($req->getArgs()) != 2) {
            echo 'Wrong arguments.' . PHP_EOL . 'Usage : db/migration/create mapping_name migration_name' . PHP_EOL;
        } else {
            $mappingName = $req->getArgs()[0];
            $mapping = Mapping::get($mappingName);
            $name = ucfirst($req->getArgs()[1]);
            $path = rtrim($mapping['config']['migrations']['path'], DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            $path .= $name . DIRECTORY_SEPARATOR . $name . '.php';
            if (file_exists($path) === false) {
                throw new FileNotReadable('can\'t find migration at "' . $path . '"');
            }
            $cl = '\\' . ltrim(rtrim($mapping['config']['provider'], '\\'), '\\') . '\\Migration::generate';
            if (is_callable($cl) === false) {
                throw new RuntimeException(
                    'Migration generate method is not callable on configured provider!'
                );
            }
            $res = call_user_func($cl, $mapping, $mappingName, $name);
            $this->write($mapping, $mappingName, $name, $res['up'], $res['down'], $res['import']);
            echo 'Migration "' . $name . '" generated.' . PHP_EOL;
            echo 'This is an automatic generation, please validate or rewrite parts of the migration.' . PHP_EOL;
            echo 'File is there:' . PHP_EOL;
            echo $path . PHP_EOL;
        }
    }
Generate code for migration.

@param Request $req current CLI request
@throws FileNotReadable if can't find migrate