@param Schema $schema

@throws SkipMigrationException
518240
public function up(Schema $schema)
    {
        /*
         * Migration is not critical
         * Old format for storing image files to the new format
         *
         * Old format(date added image):
         *    media/{Y}/{m}/
         *
         * New Format(date added item):
         *    media/{Y}/{m}/{d}/{His}/
         */

        // move covers
        $items = $this->connection->fetchAll('
            SELECT
                `id`,
                `cover`,
                `date_add`
            FROM
                `item`
            WHERE
                `cover` IS NOT NULL AND
                `cover` != "" AND
                `cover`  NOT LIKE "example/%"'
        );
        foreach ($items as $item) {
            $path = date('Y/m/d/His/', strtotime($item['date_add']));
            $file = new File($this->media_dir.$item['cover']);
            $file->move($this->media_dir.$path);
            $this->addSql('
                UPDATE
                    `item`
                SET
                    `cover` = ?
                WHERE
                    `id` = ?',
                [
                    $path.$file->getBasename(),
                    $item['id'],
                ]
            );
        }

        // move images
        $images = $this->connection->fetchAll('
            SELECT
                im.`id`,
                im.`source`,
                i.`date_add`
            FROM
                `item` AS `i`
            INNER JOIN
                `image` AS `im`
                ON
                    im.`item` = i.`id`'
        );
        foreach ($images as $image) {
            $path = date('Y/m/d/His/', strtotime($image['date_add']));
            $file = new File($this->media_dir.$image['source']);
            $file->move($this->media_dir.$path);
            $this->addSql('
                UPDATE
                    `image`
                SET
                    `source` = ?
                WHERE
                    `id` = ?',
                [
                    $path.$file->getBasename(),
                    $image['id'],
                ]
            );
        }

        // skip if no data
        $this->skipIf(!($items && $images), 'No data to migrate');
    }
152642
public function transCreateField($table, $field, $schema)
    {
        $this->transInitTable($table);
        $this->schemaUpdateTransaction[$table]['newFields'][$field] = $schema;
    }
879201
protected function generateDataTypes(array $schema)
    {
        $directory = $this->getMappingDirectory('DataType');
        foreach ($schema['datatypes'] as $dataType => $data) {
            $this->generateDataType($dataType, $data, $directory);
        }
    }
1297049
public function addAllowedSchema(SchemaInterface $schema)
    {
        $exists = false;
        foreach ($this->allowedSchemas as $allowedSchema) {
            if ($allowedSchema->getId() == $schema->getId()) {
                $exists = true;
            }
        }

        if (!$exists) {
            $this->allowedSchemas[] = $schema;
        }

        return $this;
    }
725213
public function checkIntegrity($check=true,$schema='')
	{
		$enable=$check ? 'ENABLE' : 'DISABLE';
		$tableNames=$this->getTableNames($schema);
		$db=$this->getDbConnection();
		foreach($tableNames as $tableName)
		{
			$tableName='"'.$tableName.'"';
			if(strpos($tableName,'.')!==false)
				$tableName=str_replace('.','"."',$tableName);
			$db->createCommand("ALTER TABLE $tableName $enable TRIGGER ALL")->execute();
		}
	}
793250
public function run(string $path): void
    {
        // We need to make sure migration table is available.
        $this->createMigrationRepository();

        $this->migrator->run($path);
    }
452522
public function visitSchema(Schema $schema)
    {
        return new Schema(
            $this->transformConstraintArray($schema->constraints()),
            $schema->defaultValue(),
            $schema->title(),
            $schema->description()
        );
    }
1366977
protected void setSchema(final String schema) throws DatabaseEngineException {
        try {
            this.conn.setSchema(schema);
        } catch (final Exception e) {
            throw new DatabaseEngineException(String.format("Could not set current schema to '%s'", schema), e);
        }
    }
998500
public function clone_with_new_schema($schema)
  {
    $name = $schema->fullname();
    if (AvroSchema::is_valid_type($name))
      throw new AvroSchemaParseException(
        sprintf('Name "%s" is a reserved type name', $name));
    else if ($this->has_name($name))
      throw new AvroSchemaParseException(
        sprintf('Name "%s" is already in use', $name));
    $schemata = new AvroNamedSchemata($this->schemata);
    $schemata->schemata[$name] = $schema;
    return $schemata;
  }
417189
public function setSchema($schema) {
        if(!$this->setModified('schema', $schema)->isModified()) {
            return $this;
        }
		$this->schema = $schema;
		return $this;
    }
912386
public function setSchema($schema)
    {
        $schema = array($schema);
        if (func_num_args() > 0) {
            $schema = func_get_args();
        }
        
        $error = Argument::i();
        foreach ($schema as $i => $name) {
            $error->test($i + 1, 'string');
        }
        
        $schema = implode(',', $schema);
        
        $query = $this->utility()->setSchema($schema);
        $this->query($query);
        
        return $this;
    }
1287478
public function update($schema)
    {
        $schema = $this->callSchema($schema);

        foreach ($schema->getColumns() as $column) {
            if ($this->hasColumn($column->getName())) {
                $this->modifyColumn($column);
            } else {
                $this->addColumn($column);
            }
        }

        foreach ($schema->getIndexes() as $index) {
            $this->addIndex($index);
        }

        return $this->reset();
    }
539747
public function transAlterIndex($table, $index, $schema)
    {
        $this->transInitTable($table);
        $this->schemaUpdateTransaction[$table]['alteredIndexes'][$index] = $schema;
    }
1302625
protected function validateSchema($schema)
    {
        if (!is_string($schema) || trim($schema) == '') {
            throw new Exception\InvalidArgumentException(__METHOD__ . ': Schema name must be a valid string or an empty string detected');
        }

        return $this;
    }
114115
protected function generateProperties(array $schema)
    {
        $directory = $this->getMappingDirectory('Property');
        $this->generateAbstractProperty($directory);
        foreach ($schema['properties'] as $property => $data) {
            $this->generateProperty($property, $data, $directory, $schema['datatypes']);
        }
    }
104735
protected function writeSchemaHelp($schema) {
        // Write the command description.
        $meta = Cli::val(Cli::META, $schema, []);
        $description = Cli::val('description', $meta);

        if ($description) {
            echo implode("\n", Cli::breakLines($description, 80, false)).PHP_EOL.PHP_EOL;
        }

        unset($schema[Cli::META]);

        // Add the help.
        $schema['help'] = [
            'description' => 'Display this help.',
            'type' => 'boolean',
            'short' => '?'
        ];

        echo Cli::bold('OPTIONS').PHP_EOL;

        ksort($schema);

        $table = new Table();
        $table->setFormatOutput($this->formatOutput);

        foreach ($schema as $key => $definition) {
            $table->row();

            // Write the keys.
            $keys = "--{$key}";
            if ($shortKey = Cli::val('short', $definition, false)) {
                $keys .= ", -$shortKey";
            }
            if (Cli::val('required', $definition)) {
                $table->bold($keys);
            } else {
                $table->cell($keys);
            }

            // Write the description.
            $table->cell(Cli::val('description', $definition, ''));
        }

        $table->write();
        echo PHP_EOL;

        $args = Cli::val(Cli::ARGS, $meta, []);
        if (!empty($args)) {
            echo Cli::bold('ARGUMENTS').PHP_EOL;

            $table = new Table();
            $table->setFormatOutput($this->formatOutput);

            foreach ($args as $argName => $arg) {
                $table->row();

                if (Cli::val('required', $arg)) {
                    $table->bold($argName);
                } else {
                    $table->cell($argName);
                }

                $table->cell(Cli::val('description', $arg, ''));
            }
            $table->write();
            echo PHP_EOL;
        }
    }
1156538
protected void migrateSchema() {

        try {

            Connection connection = dataSource.getConnection();
            try {

                beforeSchemaMigration(connection);

                SchemaUpdater updater = new SchemaUpdater(connection, tableName, serializer);
                if (!updater.doesTableExist()) {
                    updater.migrateToVersion1();
                }
                if (updater.isSchemaVersion1()) {
                    updater.migrateToVersion2();
                }

                afterSchemaMigration(connection);


            } finally {
                DbUtils.closeQuietly(connection);
            }

        } catch (SQLException e) {
            throw new IllegalStateException("Failed to migrate the database schema", e);
        }

    }