Create migration with given name

@param string $name

@throws Application\Exception
@throws \Koldy\Config\Exception
@throws \Koldy\Exception
@throws \Koldy\Filesystem\Exception
173283
public static function createMigration(string $name): void
    {
        $directory = Application::getApplicationPath('migrations');

        if (!is_dir($directory)) {
            Directory::mkdir($directory, 0755);
        }

        $timestamp = time();
        $className = Util::camelCase($name, null, false);
        $phpClassName = "Migration_{$timestamp}_{$className}";
        $fileName = "{$timestamp}_{$className}.php";
        $fullPath = Application::getApplicationPath("migrations/{$fileName}");

        $migrationFileContent = file_get_contents(__DIR__ . '/MigrationTemplate.php');
        $migrationFileContent = str_replace('templateClassName', $phpClassName, $migrationFileContent);
        $migrationFileContent = str_replace('templateClassGenerated', date('r'), $migrationFileContent);

        if (file_put_contents($fullPath, $migrationFileContent) === false) {
            throw new Application\Exception("Unable to write to migration file on path={$fullPath}");
        }

        Log::info("Created DB migration with name: {$name}");
        Log::info("You may now open application/migrations/{$fileName} and add your migration code");
    }
40591
protected function migrateConnectionUp($name)
    {
        $manager = $this->createManager($name);
        $lastApplied = $manager->getLast();
        echo "\n\nmigrate up $name from $lastApplied";
        $folder = \Devil::getPathOf('@app/migrations/' . $name);
        if (is_dir($folder)) {
            $d = opendir($folder);
            while ($e = readdir($d)) {
                if ('.' == $e || '..' == $e) continue;
                if (is_file($folder . '/' . $e)) {
                    $time = intval(substr($e, 2));
                    if ($time > $lastApplied) {
                        $className = '\\app\\migrations\\' . $name . '\\m_' . $time;
                        $this->migrateUp(new $className);
                    }
                }
            }
        }
        echo "\n--status:done";
    }
56787
public function createDatabase($name)
    {
        $response = $this->httpClient->request('PUT', '/'.urlencode($name));

        if ($response->status != 201) {
            throw HTTPException::fromResponse('/'.urlencode($name), $response);
        }
    }
1190607
public function setName($name)
    {
        if (empty((string) $name)) {
            throw new ConfigurationException(
                'The configuration must specify a non-empty name for the Tool Provider.',
                ConfigurationException::TOOL_PROVIDER
            );
        } else {
            $this->name = (string) $name;
        }
    }
1245454
static protected function create_connection($name)
    {
        # If the connection is already created, return.
        if (isset(self::$_connections[$name]))
            return;
        elseif (self::connectionExists($name))
            self::$_connections[$name] = new Connection(self::$_connection_data[$name], $name);
        else
            throw new Exception\RuntimeException(
                sprintf("Connection '%s' does not exist", $name)
            );
    }
408115
public function setMigrationClassName($fileName = null)
    {
        if ($this->getFileExt($this->latestFile) !== 'php') {
            throw new \Exception(APP_NS.'/Resources/Database/Migrations/ must have {xxxx_table_name.php} file types');
        }

        $fileName = (is_null($fileName)) ? $this->latestFile : $fileName;

        $file = str_replace(EXT, '', $fileName);
        $exp = '';
        $exp = preg_split('((\d+|\D+))', $file, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

        $this->migrationVersion = $exp[0];
        $this->migrationClass = $exp[1];
    }
1345652
private function bakeDatabaseConfig(string $name) : void
    {
        $options = [
            'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'db' . DS,
            'ext' => 'json'
        ];

        $this->bake('migration.dist', 'Module/db/migration', [], '', $options);
    }
1365687
public function renameFile($name, $newName)
    {
        foreach ($this->getAllFields() as $field) {
            $path = $this->getFilePath($field, $name);
            $newPath = $this->getFilePath($field, $newName);
            if (file_exists($newPath)) {
                throw new \Exception("File {$newName} already exists");
            }
            rename($path, $newPath);
        }
        if ($name == $this->owner->getAttribute($this->fileField)
            && ($files = $this->getFileList())
        ) {
            $this->owner->updateAttributes([$this->fileField => $newName]);
        }
        return true;
    }
742267
public function buildTable($name, $id)
    {
        $this->modelBuilder->build($name);
        $this->formBuilder->build($name);
        $migration = $this->migrationBuilder->buildSourceTableMigration($name);

        $this->migrateUp($migration);
    }
56292
protected function writeMigration($name, $extension, $table, $create)
    {
        $path = $this->creator->create($name, $extension, $table, $create);

        $file = pathinfo($path, PATHINFO_FILENAME);

        $this->info("Created migration: $file");
    }
1009872
private function processCreateMigration($name, $fields)
    {
        $this->migrationService->processCommand('create', $name);

        // name:type:limit:null:unique
        foreach ($fields as $fieldDefinition) {
            $fieldDefinition = explode(':', $fieldDefinition);
            $fieldDefinition = array_map(function($value) {
                return (strlen($value) === 0 ? NULL : $value);
            }, $fieldDefinition);
            $this->migrationService->processCommand('addColumn', ...$fieldDefinition);
        }

        $this->migrationService->processCommand('finalise');
        $this->migrationService->create($name);
    }
42317
public function make( $name ) {
		$this->name = ucfirst( camel_case( $name ) );
		$this->createController();
		$this->createContract();
		$this->createRequests();
	}
1134698
protected static function _buildTransport($name)
    {
        if (!isset(static::$_config[$name])) {
            throw new InvalidArgumentException(
                sprintf('The "%s" transport configuration does not exist', $name)
            );
        }

        if (is_array(static::$_config[$name]) && empty(static::$_config[$name]['className'])) {
            throw new InvalidArgumentException(
                sprintf('Transport config "%s" is invalid, the required `className` option is missing', $name)
            );
        }

        static::getRegistry()->load($name, static::$_config[$name]);
    }
1004273
public function setName($name)
    {
        assert(is_string($name));

        if ($this->_name !== null && $this->_name !== $name) {
            throw new ClientException('Should not update the name of an existing collection');
        }

        $this->_name = (string) $name;
    }
429281
private function bakeModuleConfig(string $name) : void
    {
        $options = [
            'path' => Configure::read('CsvMigrations.modules.path') . $name . DS . 'config' . DS,
            'ext' => 'json'
        ];

        $this->bake('config.dist', 'Module/config/config', [], '', $options);
        $this->bake('fields.dist', 'Module/config/fields', [], '', $options);
        $this->bake(
            'menus.dist',
            'Module/config/menus',
            ['label' => Inflector::humanize($name), 'url' => DS . Inflector::dasherize($name) . DS],
            '',
            $options
        );
    }
907458
public function package(string $name): void
    {
        $files = $this->app->make('files');

        if (\method_exists($this->app, 'vendorPath')) {
            $vendorPath = \rtrim($this->app->vendorPath(), '/');
        } else {
            $basePath = \rtrim($this->app->basePath(), '/');
            $vendorPath = "{$basePath}/vendor";
        }

        $paths = [
            "{$vendorPath}/{$name}/resources/database/migrations/",
            "{$vendorPath}/{$name}/database/migrations/",
            "{$vendorPath}/{$name}/migrations/",
        ];

        foreach ($paths as $path) {
            if ($files->isDirectory($path)) {
                $this->run($path);
            }
        }
    }
473539
protected function createComponent($name)
    {
        $result = null;

        $config = $this->getComponentConfig($name);

        if ($config !== null && isset($config['class'])) {
            $result = new $config['class'];
            if (!($result instanceof \pwf\basic\interfaces\Component)) {
                throw new \Exception('Component must implement \'Component\' interface',
                500);
            }
            $result->loadConfiguration($config);
        }

        return $result;
    }