Create a new migration at the given path.

@param string $name
@param string $eventObjectTable
@param string $actionTiming
@param string $event
@param string|null $path
@return string
768213
public function write($name, $eventObjectTable, $actionTiming, $event, $path)
    {
        $this->ensureMigrationDoesntAlreadyExist($name);

        $stub = $this->files->get($this->stubPath().'/create.stub');

        $this->files->put(
            $path = $this->getPath($name, $path),
            $this->populate($name, $eventObjectTable, $actionTiming, $event, $stub)
        );

        return $path;
    }
742267
public function buildTable($name, $id)
    {
        $this->modelBuilder->build($name);
        $this->formBuilder->build($name);
        $migration = $this->migrationBuilder->buildSourceTableMigration($name);

        $this->migrateUp($migration);
    }
1000449
protected function createAction($name, $actionTemplate, WorkflowDefinition $definition = null)
    {
        $type = $actionTemplate['type'];
        if (!$type || !class_exists($type)) {
            throw new Exception(_t(
                'WorkflowTemplate.INVALID_TEMPLATE_ACTION',
                'Invalid action class specified in template'
            ));
        }

        $action = $type::create();

        $action->Title = $name;

        if (isset($actionTemplate['properties']) && is_array($actionTemplate['properties'])) {
            foreach ($actionTemplate['properties'] as $prop => $val) {
                $action->$prop = $val;
            }
        }

        // Deal with User + Group many_many relations on an action
        $this->addManyManyToObject($action, $actionTemplate);

        if ($definition) {
            $action->WorkflowDefID = $definition->ID;
        }

        $action->write();

        return $action;
    }
680022
public function forDynamicMember($name, $memberOptions = null)
	{
		$propertyMap = $this->typeMap->getPropertyMap($name);
		if ($propertyMap !== null) {
			throw new PapperConfigurationException(sprintf('Unable to create dynamic destination member %s on type %s because it already exists in type', $name, $this->typeMap->getDestinationType()));
		}

		$setter = $this->typeMap->getDestinationType() === 'stdClass'
			? new StdClassPropertySetter($name)
			: new PropertyAccessSetter($name);

		$this->typeMap->addPropertyMap($propertyMap = new PropertyMap($setter));

		$memberOptions = is_array($memberOptions) ? $memberOptions : array($memberOptions);
		foreach ($memberOptions as $memberOption) {
			if (!$memberOption instanceof MemberOptionInterface) {
				throw new PapperConfigurationException('Member options must be array or instance of Papper\MemberOptionInterface');
			}
			$memberOption->apply($this->typeMap, $propertyMap);
		}
		return $this;
	}
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");
    }
1191249
protected function getMigrationCapsule(MigrationInput $input, $resource, $name, $isCreate = true)
    {
        $migration = MigrationCapsule::get($name);
        $migration->path = $this->getMigrationFullName($name);
        $migration->resource = $resource;
        $migration->className = $this->makeCreateTableClassName(Helpers::makeTableName($this->tableName));
        $migration->isCreate = $isCreate;
        $migration->withoutTimestamps = $input->withoutTimestamps;
        $migration->withSoftDelete = $input->withSoftDelete;

        return $migration;
    }
330643
public function rowAction ($name)
    {
        $oper = $this->getRequest()->get('oper', false);
        if (!in_array($oper, array('add', 'edit', 'del'))){
            throw new \InvalidArgumentException(sprintf('Event type: %s is not valid', $oper));
        }
        
        $eventType = 'neutron_datagrid.onRow' . ucfirst($oper);
        
        $event = new RowEvent($name, $this->getRequest()->get('id'));

        $this->container->get('event_dispatcher')->dispatch($eventType, $event);
        
        return new JsonResponse(array(
            'errors'  => $event->getErrors(), 
            'success' => $event->getSuccess(), 
            'id'      => $event->getId(),
            'data'    => $event->getData()
        ));
    }
385434
protected function replaceMigration($path, $table, $tableClassName)
    {
        $stub = str_replace(
            ['{{table}}', '{{tableClassName}}'],
            [$table, $tableClassName],
            $this->files->get(__DIR__.'/stubs/jobs.stub')
        );

        $this->files->put($path, $stub);
    }
1362205
protected function dispatch($eventName, ActionEvent $event = null)
    {
        if ($event == null) {
            $event = new DefaultActionEvent();
        }

        $this->getDispatcher()->dispatch($eventName, $event);
    }
430105
public function actionCreate($name, $module = false)
    {
        if (empty($module)) {
            return parent::actionCreate($name);
        }
        
        if (!isset($this->migrationPath[$module])) {
            throw new Exception("The module \"$module\" does not exist in the application modules configuration.");
        }
        
        // apply custom migration code to generate new migrations for a module specific path
        if (!preg_match('/^[\w\\\\]+$/', $name)) {
            throw new Exception('The migration name should contain letters, digits, underscore and/or backslash characters only.');
        }
        
        $className = 'm'.gmdate('ymd_His').'_'.$name;
        
       
        $migrationPath = $this->migrationPath[$module];
        
        $file = $migrationPath . DIRECTORY_SEPARATOR . $className . '.php';
        if ($this->confirm("Create new migration '$file'?")) {
            $content = $this->generateMigrationSourceCode([
                'name' => $name,
                'className' => $className,
                'namespace' => null,
            ]);
            FileHelper::createDirectory($migrationPath);
            file_put_contents($file, $content);
            $this->stdout("New migration created successfully.\n", Console::FG_GREEN);
        }
    }
1030331
protected function promptMigration($name)
    {
        $this->line('');

        if ($this->confirm('Would you like to create the migration for the model? [Yes|no]'))
        {
            $this->call('transit:migration', ['table' => str_plural($name)]);
        }
    }
635983
public static function newInstance(Entity_Interface $entity, $path, $name = null)
  {
    if (is_null($name)) {
      $name = $entity->basename();
    }
    $instance = new static($name, $path);
    /* @var $instance Entity_Virtual */
    $instance->_realEntity = $entity;

    return $instance;
  }
381839
protected function getMigrationFile($name, $path = false)
    {
        $path = $path ? $path : $this->migrationPath;
        return $path . DIRECTORY_SEPARATOR . $name . '.php';
    }
328750
public function triggerEvent($name, Event $event = null)
    {
        return $this->e->trigger($name, $event);
    }
288179
public function buildFieldMigrationForTable($name, $type, $indexed, $tableName)
    {
        $path = $this->getMigrationPath($tableName, $name);
        $migration = $this->getTableFieldMigrationName($name, $tableName);

        $contents = view('_hierarchy::migrations.field', [
            'field'     => $name,
            'table'     => source_table_name($tableName),
            'migration' => $migration,
            'type'      => $this->getColumnType($type),
            'indexed'   => $indexed
        ])->render();

        $this->write($path, $contents);

        return $this->getMigrationClassPath($migration);
    }
910181
public function getEvent(string $name, string $table = null): ?callable
    {
        return $this->connection->getEventHandler()->getEvent($name, $table);
    }
574815
public static function path( $name, $time = null )
	{
		if ( is_null( $time ) )
		{
			$time = time();
		}
		
		$namespace = null;
		
		if ( strpos( $name, '::' ) !== false )
		{
			list( $namespace, $name ) = explode( '::', $name );
		}
		
		$name = explode( '/', $name );
		
		foreach( $name as $key => $value )
		{
			$name[$key] = \CCStr::clean_url( $value, '_' );
		}
		
		$name = implode( '/', $name );
		
		return \CCPath::get( ( $namespace ? $namespace.'::' : '' ) .$name.'_'.$time, \ClanCats::directory( 'migration' ), '.sql' );
	}