callSchema

@param   callable|Schema $schema

@return  Schema
508103
protected function callSchema($schema)
    {
        if (!$schema instanceof Schema && is_callable($schema)) {
            $s = $this->getSchema();

            $schema($s);

            $schema = $s;
        }

        if (!$schema instanceof Schema) {
            throw new \InvalidArgumentException('Argument 1 should be Schema object.');
        }

        return $schema;
    }
610342
public function parse($schema)
    {
        $fields = $this->splitIntoFields($schema);

        foreach ($fields as $field) {
            $segments = $this->parseSegments($field);

            if ($this->fieldNeedsForeignConstraint($segments)) {
                unset($segments['options']['foreign']);

                // If the user wants a foreign constraint, then
                // we'll first add the regular field.
                $this->addField($segments);

                // And then add another field for the constraint.
                $this->addForeignConstraint($segments);

                continue;
            }

            $this->addField($segments);
        }

        return $this->schema;
    }
1199737
public function addSchema(string $name, Schema $schema): self
    {
        $this->schemas[$name] = $schema;

        return $this;
    }
428096
protected function addModulesToSchema(array $schema, string $module): array
    {
        if (isset($schema['definitions']['moduleName'])) {
            $modules = Utility::getModules();
            if (!empty($modules)) {
                $schema['definitions']['moduleName']['enum'] = array_values($modules);
            }
        }

        return $schema;
    }
991149
public function getSchemaTables(Schema $schema)
    {
        $tables = [];

        foreach ($this->tables->keys() as $name) {
            /** @var BaseTable $table */
            $table = $this->tables[$name];
            $tables[$name] = $table->buildTable($schema, $name, $this->charset, $this->collate);
        }

        foreach ($this->tableGenerators as $generator) {
            $table = $generator($schema);

            if (is_array($table)) {
                /** @var Table[] $table */
                foreach ($table as $t) {
                    $alias = str_replace($this->prefix, '', $t->getName());
                    $t->addOption('alias', $alias);
                    $t->addOption('charset', $this->charset);
                    $t->addOption('collate', $this->collate);
                    $tables[$alias] = $t;
                }
            } else {
                /** @var Table $table */
                $alias = str_replace($this->prefix, '', $table->getName());
                $table->addOption('alias', $alias);
                $table->addOption('charset', $this->charset);
                $table->addOption('collate', $this->collate);
                $tables[$alias] = $table;
            }
        }

        return $tables;
    }
353633
public function optional(array $schema) : Assoc
    {
        return $this->pipe(function (array $values) use ($schema) : Result {
            $result = Result::success();

            foreach ($schema as $key => $validator) {
                if (!isset($values[$key])) {
                    continue;
                }

                $result = $result->concat(
                    $validator
                        ->validate($values[$key])
                        ->map(function ($error) use ($key) {
                            return "$key: $error";
                        })
                );
            }

            return $result;
        });
    }
111271
public function schema($request)
    {
        $formName = $request->param('FormName');
        if (!in_array($formName, $this->formNames)) {
            return parent::schema($request);
        }

        return $this->generateSchemaForForm($formName, $request);
    }
784359
protected function add_additional_fields_schema( $schema ) {
		if ( empty( $schema['title'] ) ) {
			return $schema;
		}

		/**
		 * Can't use $this->get_object_type otherwise we cause an inf loop.
		 */
		$object_type = $schema['title'];

		$additional_fields = $this->get_additional_fields( $object_type );

		foreach ( $additional_fields as $field_name => $field_options ) {
			if ( ! $field_options['schema'] ) {
				continue;
			}

			$schema['properties'][ $field_name ] = $field_options['schema'];
		}

		return $schema;
	}
1289901
public function parseSchema(\stdClass $schema, Context $context)
    {
        if ($this->isProcessed($schema, $this->parsedSchemas)) {
            return $schema;
        }

        $version = $this->getVersion($schema);
        $constraints = $this->registry->getConstraints($version);
        $constraints = $this->filterConstraintsForSchema($constraints, $schema);

        foreach ($constraints as $constraint) {
            $constraint->normalize($schema, $context, $this);
        }

        return $schema;
    }
843737
public function upgradeSchema(Schema $schema)
    {
        $pp = $schema->getTable('PagePaths');
        if (!$pp->hasColumn('ppGeneratedFromURLSlugs')) {
            $pp->addColumn('ppGeneratedFromURLSlugs', 'boolean', ['notnull' => true, 'unsigned' => true, 'default' => 0]);
        }

        $ms = $schema->getTable('MultilingualSections');
        if (!$ms->hasColumn('msNumPlurals')) {
            $ms->addColumn('msNumPlurals', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 2]);
            $this->updateSectionPlurals = true;
        }
        if (!$ms->hasColumn('msPluralRule')) {
            $ms->addColumn('msPluralRule', 'string', ['notnull' => true, 'length' => 400, 'default' => '(n != 1)']);
            $this->updateSectionPlurals = true;
        }
        if (!$ms->hasColumn('msPluralCases')) {
            $ms->addColumn('msPluralCases', 'string', ['notnull' => true, 'length' => 1000, 'default' => "one@1\nother@0, 2~16, 100, 1000, 10000, 100000, 1000000, …"]);
            $this->updateSectionPlurals = true;
        }
        $mt = $schema->getTable('MultilingualTranslations');
        if (!$mt->hasColumn('msgidPlural')) {
            $mt->addColumn('msgidPlural', 'text', ['notnull' => false]);
            $this->updateMultilingualTranslations = true;
        }
        if (!$mt->hasColumn('msgstrPlurals')) {
            $mt->addColumn('msgstrPlurals', 'text', ['notnull' => false]);
            $this->updateMultilingualTranslations = true;
        }

        $cms = $schema->getTable('ConversationMessages');
        if (!$cms->hasColumn('cnvMessageAuthorName')) {
            $cms->addColumn('cnvMessageAuthorName', 'string', ['notnull' => false, 'length' => 255]);
        }
        if (!$cms->hasColumn('cnvMessageAuthorEmail')) {
            $cms->addColumn('cnvMessageAuthorEmail', 'string', ['notnull' => false, 'length' => 255]);
        }
        if (!$cms->hasColumn('cnvMessageAuthorWebsite')) {
            $cms->addColumn('cnvMessageAuthorWebsite', 'string', ['notnull' => false, 'length' => 255]);
        }
    }
159894
protected function updateSchema(Schema $schema) {
		foreach($schema->getJoins() as $join) {
			$assoc = $join->getAssociation();
			$parent = $join->getParent();
			if (is_null($parent))
				$assoc->appendJoin($this, $this->alias, $join->getAlias(), true);
			else {
				$alias = $schema->getJoin($parent)->getAlias();
				$assoc->appendJoin($this, $alias, $join->getAlias(), true);
			}
		}
	}
1071619
protected function matchSchema($schema)
    {
        if (empty($this->schema)) {
            return true;
        }

        if (strpos($schema, $this->schema) !== false) {
            return true;
        }

        return false;
    }
706679
public function setSchema(Schema $obj_schema)
    {
        $this->obj_schema = $obj_schema;
        $this->setKind($obj_schema->getKind());
        return $this;
    }
718058
public function create(Schema $schema)
    {
        $currentDbSchema = $this->connection->getSchemaManager()->createSchema();

        $dbSchema = new DBALSchema(
            $currentDbSchema->getTables(),
            $currentDbSchema->getSequences(),
            $this->connection->getSchemaManager()->createSchemaConfig()
        );

        foreach ($schema->types() as $type) {
            $tableName = $this->tableName($schema->name(), $type->name());

            if ($dbSchema->hasTable($tableName)) {
                throw DoctrineStorageException::tableAlreadyExists($tableName);
            }

            $this->createTable($dbSchema, $schema->name(), $type);
        }

        $queries = $dbSchema->toSql($this->connection->getDatabasePlatform());

        $this->executeQueries($queries);
    }
1284763
private function createSchemaForDownMethod($schema, $meta)
    {
        // If the user created a table, then for the down
        // method, we should drop it.
        if ($meta['action'] == 'create') {
            return sprintf("Schema::drop('%s');", $meta['table']);
        }

        // If the user added columns to a table, then for
        // the down method, we should remove them.
        if ($meta['action'] == 'add') {
            $fields = $this->constructSchema($schema, 'Drop');

            return $this->insert($fields)->into($this->getChangeSchemaWrapper());
        }

        // If the user removed columns from a table, then for
        // the down method, we should add them back on.
        if ($meta['action'] == 'remove') {
            $fields = $this->constructSchema($schema);

            return $this->insert($fields)->into($this->getChangeSchemaWrapper());
        }

        // Otherwise, we have no idea how to proceed.
        throw new GeneratorException;
    }
1161391
public function getSchema(): ?Builder
    {
        if (!$this->hasSchema()) {
            $this->setSchema($this->getDefaultSchema());
        }
        return $this->schema;
    }
237472
final public function preUp(Schema $schema)
    {
        $this->prepare(array_map(function (string $value) : string {
            return $this->getFullPath($value);
        }, $this->getUpgradeMigrations()));
    }