Handles the content create migration action type
183409
protected function create($step)
    {
        $contentService = $this->repository->getContentService();
        $locationService = $this->repository->getLocationService();
        $contentTypeService = $this->repository->getContentTypeService();

        $contentTypeIdentifier = $step->dsl['content_type'];
        $contentTypeIdentifier = $this->referenceResolver->resolveReference($contentTypeIdentifier);
        /// @todo use a contenttypematcher
        $contentType = $contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);

        $contentCreateStruct = $contentService->newContentCreateStruct($contentType, $this->getLanguageCode($step));

        $this->setFields($contentCreateStruct, $step->dsl['attributes'], $contentType, $step);

        if (isset($step->dsl['always_available'])) {
            $contentCreateStruct->alwaysAvailable = $step->dsl['always_available'];
        } else {
            // Could be removed when https://github.com/ezsystems/ezpublish-kernel/pull/1874 is merged,
            // but we strive to support old eZ kernel versions as well...
            $contentCreateStruct->alwaysAvailable = $contentType->defaultAlwaysAvailable;
        }

        if (isset($step->dsl['remote_id'])) {
            $contentCreateStruct->remoteId = $step->dsl['remote_id'];
        }

        if (isset($step->dsl['section'])) {
            $sectionKey = $this->referenceResolver->resolveReference($step->dsl['section']);
            $section = $this->sectionMatcher->matchOneByKey($sectionKey);
            $contentCreateStruct->sectionId = $section->id;
        }

        if (isset($step->dsl['owner'])) {
            $owner = $this->getUser($step->dsl['owner']);
            $contentCreateStruct->ownerId = $owner->id;
        }

        // This is a bit tricky, as the eZPublish API does not support having a different creator and owner with only 1 version.
        // We allow it, hoping that nothing gets broken because of it
        if (isset($step->dsl['version_creator'])) {
            $realContentOwnerId = $contentCreateStruct->ownerId;
            if ($realContentOwnerId == null) {
                $realContentOwnerId = $this->repository->getCurrentUser()->id;
            }
            $versionCreator = $this->getUser($step->dsl['version_creator']);
            $contentCreateStruct->ownerId = $versionCreator->id;
        }

        if (isset($step->dsl['modification_date'])) {
            $contentCreateStruct->modificationDate = $this->toDateTime($step->dsl['modification_date']);
        }

        // instantiate a location create struct from the parent location:
        // BC
        $locationId = isset($step->dsl['parent_location']) ? $step->dsl['parent_location'] : (
            isset($step->dsl['main_location']) ? $step->dsl['main_location'] : null
        );
        // 1st resolve references
        $locationId = $this->referenceResolver->resolveReference($locationId);
        // 2nd allow to specify the location via remote_id
        $locationId = $this->locationManager->matchLocationByKey($locationId)->id;
        $locationCreateStruct = $locationService->newLocationCreateStruct($locationId);

        if (isset($step->dsl['location_remote_id'])) {
            $locationCreateStruct->remoteId = $step->dsl['location_remote_id'];
        }

        if (isset($step->dsl['priority'])) {
            $locationCreateStruct->priority = $step->dsl['priority'];
        }

        if (isset($step->dsl['is_hidden'])) {
            $locationCreateStruct->hidden = $step->dsl['is_hidden'];
        }

        if (isset($step->dsl['sort_field'])) {
            $locationCreateStruct->sortField = $this->sortConverter->hash2SortField($step->dsl['sort_field']);
        } else {
            $locationCreateStruct->sortField = $contentType->defaultSortField;
        }

        if (isset($step->dsl['sort_order'])) {
            $locationCreateStruct->sortOrder = $this->sortConverter->hash2SortOrder($step->dsl['sort_order']);
        } else {
            $locationCreateStruct->sortOrder = $contentType->defaultSortOrder;
        }

        $locations = array($locationCreateStruct);

        // BC
        $other_locations = isset($step->dsl['other_parent_locations']) ? $step->dsl['other_parent_locations'] : (
            isset($step->dsl['other_locations']) ? $step->dsl['other_locations'] : null
        );
        if (isset($other_locations)) {
            foreach ($other_locations as $locationId) {
                $locationId = $this->referenceResolver->resolveReference($locationId);
                $locationId = $this->locationManager->matchLocationByKey($locationId)->id;
                $secondaryLocationCreateStruct = $locationService->newLocationCreateStruct($locationId);
                array_push($locations, $secondaryLocationCreateStruct);
            }
        }

        // create a draft using the content and location create struct and publish it
        $draft = $contentService->createContent($contentCreateStruct, $locations);
        $content = $contentService->publishVersion($draft->versionInfo);

        if (isset($step->dsl['object_states'])) {
            $this->setObjectStates($content, $step->dsl['object_states']);
        }

        // 2nd part of the hack: re-set the content owner to its intended value
        if (isset($step->dsl['version_creator']) || isset($step->dsl['publication_date'])) {
            $contentMetaDataUpdateStruct = $contentService->newContentMetadataUpdateStruct();

            if (isset($step->dsl['version_creator'])) {
                $contentMetaDataUpdateStruct->ownerId = $realContentOwnerId;
            }
            if (isset($step->dsl['publication_date'])) {
                $contentMetaDataUpdateStruct->publishedDate = $this->toDateTime($step->dsl['publication_date']);
            }
            // we have to do this to make sure we preserve the custom modification date
            if (isset($step->dsl['modification_date'])) {
                $contentMetaDataUpdateStruct->modificationDate = $this->toDateTime($step->dsl['modification_date']);
            }

            $contentService->updateContentMetadata($content->contentInfo, $contentMetaDataUpdateStruct);
        }

        $this->setReferences($content, $step);

        return $content;
    }
650529
public function actionMigrate()
    {
        ignore_user_abort(true);
        set_time_limit(0);
        
        // Don't let the user get to this action if they haven't setup a DSN yet.
        if (Yii::app()->session['dsn'] == "")
            $this->redirect($this->createUrl('/'));

        $this->render('migrate');
    }
1169193
def init(ctx):
    ''''''

    log.info('Apply DB migrations if needed')
    ctx.invoke(migrate, record=True)

    ctx.invoke(index)

    if IS_TTY:
        text = _('Do you want to create a superadmin user?')
        if click.confirm(text, default=True):
            user = ctx.invoke(user_commands.create)
            ctx.invoke(user_commands.set_admin, email=user.email)

        text = _('Do you want to import some data-related license?')
        if click.confirm(text, default=True):
            ctx.invoke(licenses)

        text = _('Do you want to create some sample data?')
        if click.confirm(text, default=True):
            ctx.invoke(generate_fixtures)

    success(_('Your udata instance is ready!'))
1352733
function migrate($original_index, $new_index, $scroll_id = null, $errors = 0, $page = 1)
    {

        if ($page == 1) {

            $pages = (int)ceil($this->es->connection($this->connection)->index($original_index)->count() / $this->size);

            $this->output->progressStart($pages);

            $documents = $this->es->connection($this->connection)->index($original_index)->type("")
                ->scroll($this->scroll)
                ->take($this->size)
                ->response();

        } else {

            $documents = $this->es->connection($this->connection)->index($original_index)->type("")
                ->scroll($this->scroll)
                ->scrollID($scroll_id)
                ->response();

        }

        if (isset($documents["hits"]["hits"]) and count($documents["hits"]["hits"])) {

            $data = $documents["hits"]["hits"];

            $params = [];

            foreach ($data as $row) {

                $params["body"][] = [

                    'index' => [
                        '_index' => $new_index,
                        '_type' => $row["_type"],
                        '_id' => $row["_id"]
                    ]

                ];

                $params["body"][] = $row["_source"];

            }

            $response = $this->es->connection($this->connection)->raw()->bulk($params);

            if (isset($response["errors"]) and $response["errors"]) {

                if (!$this->option("hide-errors")) {

                    if ($this->option("skip-errors")) {
                        $this->warn("\n" . json_encode($response["items"]));
                    } else {
                        return $this->warn("\n" . json_encode($response["items"]));
                    }

                }

                $errors++;
            }

            $this->output->progressAdvance();

        } else {

            // Reindexing finished

            $this->output->progressFinish();

            $total = $this->es->connection($this->connection)->index($original_index)->count();

            if ($errors > 0) {
                return $this->warn("$total documents reindexed with $errors errors.");
            } else {
                return $this->info("$total documents reindexed $errors errors.");
            }

        }

        $page++;

        $this->migrate($original_index, $new_index, $documents["_scroll_id"], $errors, $page);
    }
961237
private function migrateDataFromLegacyFormat(){

        if(count($this->trees) > 0){

            //tree attributes to be migrated.
           $mapping = array(
              'editClassUrl' => array(
                'attr'   => 'selectClass',
                'action' => array(
                    'id'      => 'edit_class',
                    'name'    => 'edit class',
                    'group'   => 'none',
                    'context' => 'class',
                    'binding' => 'load'
                ) 
              ),
              'editInstanceUrl' => array(
                'attr'   => 'selectInstance',
                'action' => array(
                    'id'      => 'edit_instance',
                    'name'    => 'edit instance',
                    'group'   => 'none',
                    'context' => 'instance',
                    'binding' => 'load'
                ) 
              ),
              'addInstanceUrl'  => array(
                'attr'   => 'addInstance',
                'action' => array(
                    'id'      => 'add_instance',
                    'name'    => 'add instance',
                    'group'   => 'none',
                    'context' => 'instance',
                    'binding' => 'instantiate'
                ) 
              ),
              'addSubClassUrl'  => array(
                'attr'   => 'addClass',
                'action' => array(
                    'id'      => 'add_class',
                    'name'    => 'add class',
                    'group'   => 'none',
                    'context' => 'class',
                    'binding' => 'subClass'
                ) 
              ),
              'deleteUrl' => array(
                'attr'   => 'addClass',
                'action' => array(
                    'id'      => 'add_class',
                    'name'    => 'add class',
                    'group'   => 'none',
                    'context' => 'class',
                    'binding' => 'subClass'
                ) 
              ),
              'moveInstanceUrl' => array(
                'attr'   => 'moveInstance',
                'action' => array(
                    'id'      => 'move',
                    'name'    => 'move',
                    'group'   => 'none',
                    'context' => 'instance',
                    'binding' => 'moveNode'
                ) 
              )
           );

           foreach($this->trees as $index => $tree){
               $needMigration = false;
               $treeAttributes = $tree->getAttributes();
            
               //check if this attribute needs a migration
               foreach($treeAttributes as $attr){
                    if(array_key_exists($attr, $mapping)){
                        $needMigration = true;
                        break;
                    } 
               }
               if($needMigration){
                    $newData = array();

                    //migrate the tree
                    foreach($treeAttributes as $attr){
                        //if the attribute belongs to the mapping
                        if(array_key_exists($attr, $mapping)){
                            $url = $tree->get($attr);
                            $actionName = false;
    
                            //try to find an action with the same url
                            foreach($this->actions as $action){
                                if($action->getRelativeUrl() == $url){
                                    $actionName = $action->getId();
                                    break;
                                }
                            }
                            if($actionName){
                                $newData[$mapping[$attr]['attr']] = $actionName;
                            } else {
    
                                //otherwise create a new action from the mapping
                                $newData[$mapping[$attr]['attr']] = $mapping[$attr]['action']['id'];
                                $actionData = $mapping[$attr]['action'];
                                $actionData['url'] = $url;
                                
                                list($extension, $controller, $action) = explode('/', trim($url, '/'));
                                $actionData['extension'] = $extension;
                                $actionData['controller'] = $controller;
                                $actionData['action'] = $action;
                                
                                $this->actions[] = new Action($actionData); 
                            }
                        } else {
                            $newData[$attr] = $tree->get($attr);
                        }
                    }
    
                    //the tree is replaced
                    $this->trees[$index] = new Tree($newData);
               }
           }
        }
    }
878833
void onPartitionMigrate(MigrationInfo migrationInfo) {
        Iterator<WaitSetEntry> it = queue.iterator();
        int partitionId = migrationInfo.getPartitionId();
        while (it.hasNext()) {
            if (Thread.currentThread().isInterrupted()) {
                return;
            }
            WaitSetEntry entry = it.next();
            if (!entry.isValid()) {
                continue;
            }

            Operation op = entry.getOperation();
            if (partitionId == op.getPartitionId()) {
                entry.setValid(false);
                PartitionMigratingException pme = new PartitionMigratingException(nodeEngine.getThisAddress(),
                        partitionId, op.getClass().getName(), op.getServiceName());
                op.sendResponse(pme);
                it.remove();
            }
        }
    }
83680
private function writeMigration($name, $eventObjectTable, $actionTiming, $event)
    {
        $file = pathinfo($this->creator->write(
            $name,
            $eventObjectTable,
            $actionTiming,
            $event,
            $this->getMigrationPath()
        ), PATHINFO_FILENAME);

        $this->line("<info>Created Migration:</info> {$file}");
    }
213686
def create_migration(self, repos, lock_repositories=github.GithubObject.NotSet, exclude_attachments=github.GithubObject.NotSet):
        
        assert isinstance(repos, (list, tuple)), repos
        assert all(isinstance(repo, (str, unicode)) for repo in repos), repos
        assert lock_repositories is github.GithubObject.NotSet or isinstance(lock_repositories, bool), lock_repositories
        assert exclude_attachments is github.GithubObject.NotSet or isinstance(exclude_attachments, bool), exclude_attachments
        post_parameters = {
            "repositories": repos
        }
        if lock_repositories is not github.GithubObject.NotSet:
            post_parameters["lock_repositories"] = lock_repositories
        if exclude_attachments is not github.GithubObject.NotSet:
            post_parameters["exclude_attachments"] = exclude_attachments
        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            "/user/migrations",
            input=post_parameters,
            headers={
                "Accept": Consts.mediaTypeMigrationPreview
            }
        )
        return github.Migration.Migration(self._requester, headers, data, completed=True)
453855
def handle(self, *args, **options):
        

        from categories.migration import migrate_app
        from categories.settings import MODEL_REGISTRY
        if options['app_names']:
            for app in options['app_names']:
                migrate_app(None, app)
        else:
            for app in MODEL_REGISTRY:
                migrate_app(None, app)
89834
public function flushContentTypeAction() {
        $postData = $this->getRequest()->getPost();
        if ( ! isset($postData['ctype'])) {
            $this->_getSession()->addError($this->__('Missing URL post data'));
        } else {
            $ctype = $postData['ctype'];
            Mage::dispatchEvent('turpentine_varnish_flush_content_type',
                array('ctype' => $ctype));
            $result = Mage::getModel('turpentine/varnish_admin')
                ->flushContentType($ctype);
            foreach ($result as $name => $value) {
                if ($value === true) {
                    $this->_getSession()
                        ->addSuccess(Mage::helper('turpentine/data')
                            ->__('Flushed matching content-types for: ').$name);
                } else {
                    $this->_getSession()
                        ->addError(Mage::helper('turpentine/data')
                            ->__('Error flushing matching content-types on: ').$name);
                }
            }
        }
        $this->_redirect('*/cache');
    }
835798
def post_migrate(cls, sender=None, **kwargs):
        
        ContentType = apps.get_model('contenttypes', 'ContentType')

        for model_name, proxy_model in sender.get_proxy_models().items():
            ctype, created = ContentType.objects.get_or_create(app_label=sender.label, model=model_name)
            if created:
                sender.grant_permissions(proxy_model)
1258052
public function generateMigration()
    {
        if (!$this->confirm('Do you want to create a migration?')) {
            return;
        }

        $this->console->call('generate:migration', [
            'name' => "create_{$this->getEntities()}_table",
            '--fields' => $this->console->option('fields'),
            '--force' => $this->console->option('force'),
        ]);
    }
103943
def pre_migrate(cls, sender=None, **kwargs):
        
        ContentType = apps.get_model('contenttypes', 'ContentType')
        try:
            queryset = ContentType.objects.filter(app_label=sender.label)
            for ctype in queryset.exclude(model__in=sender.get_proxy_models().keys()):
                model = ctype.model_class()
                if model is None:
                    sender.revoke_permissions(ctype)
                    ContentType.objects.get(app_label=sender.label, model=ctype).delete()
        except DatabaseError:
            return
225538
function(action, method, sysImports, options, channel, req, res) {
    var self = this;

    if (this.actions[action] && (this.actions[action].rpc || 'invoke' === method)) {
      if ('invoke' === method) {
        var imports = (req.method === 'GET' ? req.query : req.body);

        // @todo add files support
        this.actions[action].invoke(imports, channel, sysImports, [], function(err, exports) {
          if (err) {
            self.log(err, channel, 'error');
          }

          res.contentType(DEFS.CONTENTTYPE_JSON);
          if (err) {
            res.send(err, 500);
          } else {
            res.send(exports);
          }
        });
      } else {
        this.actions[action].rpc(method, sysImports, options, channel, req, res);
      }
    } else {
      res.send(404);
    }
  }
62763
public function process()
    {
        // Migrate init - to create migration table
        $name = $this->argument('name');

        if (!is_null($name)) {
            if (string_has($name, ',')) {
                $this->seeder()->executeOnly($name);
            } else {
                $this->seeder()->executeOnly($name);
            }
        }

        $this->seeder()->run();

        $this->info('Seeding Completed Successfully!');
    }
1095659
public function formAction(Request $request, $contentTypeId)
    {
        $contentType = $this->get('open_orchestra_model.repository.content_type')->findOneByContentTypeIdInLastVersion($contentTypeId);
        $this->denyAccessUnlessGranted(ContributionActionInterface::EDIT, $contentType);

        $newContentType = $this->get('open_orchestra_backoffice.manager.content_type')->duplicate($contentType);
        $action = $this->generateUrl('open_orchestra_backoffice_content_type_form', array('contentTypeId' => $contentTypeId));
        $form = $this->createContentTypeForm($request, array(
            'action' => $action,
            'enable_delete_button' => $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(BusinessActionInterface::DELETE, $contentType),
            'delete_button' => $this->isGranted(ContributionActionInterface::DELETE, $newContentType),
            'need_link_to_site_defintion' => false,
        ), $newContentType);

        $form->handleRequest($request);
        if ('PATCH' !== $request->getMethod()) {
            if ($form->isValid()) {
                $newContentType->setVersion(((int)$newContentType->getVersion()) + 1);
                $documentManager = $this->get('object_manager');
                $documentManager->persist($newContentType);
                $documentManager->flush();

                $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('open_orchestra_backoffice.form.content_type.success'));
                $this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_UPDATE, new ContentTypeEvent($newContentType));
            }
        }

        return $this->renderAdminForm($form);
    }
405569
public function process()
    {
        // Migrate init - to create migration table
        $type = $this->argument('type');

        $migration = Migrator::instance($this);
        $migration->getLatestMigration()
                  ->setMigrationClassName();

        if ($type == '' || $type == 'up') {
            $migration->updateMigration();
        } else {
            $migration->updateMigration('down');
        }

        $this->info('Migration Completed Successfully!');
    }