Register the "schema:update" command.

@return void
968975
protected function registerUpdateCommand()
    {
        $this->app->singleton('command.schema.update', function ($app) {
            return new SchemaUpdateCommand(
                $app['datamapper.classfinder'],
                $app['datamapper.entity.scanner'],
                $app['datamapper.schema.builder'],
                $app['datamapper.eloquent.generator'],
                $app['config']['datamapper']
            );
        });
    }
119761
public function apply()
    {
        Schema::create(Model::TABLE_NAME, function (Blueprint $table) {
            $table->increments(Model::FIELD_ID);
            $table->string(Model::FIELD_TITLE, Model::LENGTH_TITLE);
            $table->softDeletes();
            $table->timestamps();
        });
    }
1188401
public function registerConsole()
    {
        $this->commands(TypeMakeCommand::class);
        $this->commands(QueryMakeCommand::class);
        $this->commands(MutationMakeCommand::class);
    }
1113488
public function addSchema(string $schema) : void
    {
        $work = $schema;
        if ($work{0} != '/') {
            $work = getcwd()."/$work";
        }
        if (!file_exists($work)) {
            $this->notice("`\"$schema\"` for `{$this->database}` not found, skipping.");
            return;
        }
        $this->schemas[] = file_get_contents($work);
        $this->success("Loaded $schema.");
    }
1165205
private function registerCommands()
    {
        $this->app['commands.drawbridge.migrations'] = $this->app->share(function($app)
        {
            return new MigrationsCommand($app);
        });

        $this->commands(
            array(
                 'commands.drawbridge.migrations'
            )
        );
    }
1257493
protected function registerUpdateCommand()
    {
        $this->app->singleton('command.appupdate', function (Container $app) {
            $events = $app['events'];

            return new AppUpdate($events);
        });
    }
1083224
protected function registerMakeCommand()
    {
        $this->app->bindShared('migration.creator', function($app)
        {
            return new MigrationCreator($app['files']);
        });

        $this->app->bindShared('command.migrate.make', function($app)
        {
            $creator = $app['migration.creator'];

            $packagePath = $app['path.base'] .DS .'vendor';

            return new MakeMigrationCommand($creator, $packagePath);
        });
    }
189745
protected function registerRepository()
    {
        $this->app->singleton('neoeloquent.migration.repository', function($app)
        {
            $model = new MigrationModel;

            $label = $app['config']['database.migrations_node'];

            if (isset($label)) {
                $model->setLabel($label);
            }

            return new DatabaseMigrationRepository(
                $app['db'],
                $app['db']->connection('neo4j')->getSchemaBuilder(),
                $model
            );
        });
    }
179296
public function upgradeSchema(Schema $schema)
    {
        /* refresh CollectionVersionBlocks, CollectionVersionBlocksCacheSettings tables */
        $cvb = $schema->getTable('CollectionVersionBlocks');
        if (!$cvb->hasColumn('cbOverrideBlockTypeCacheSettings')) {
            $cvb->addColumn('cbOverrideBlockTypeCacheSettings', 'boolean', ['default' => 0]);
        }

        if (!$schema->hasTable('CollectionVersionBlocksCacheSettings')) {
            $cvbcs = $schema->createTable('CollectionVersionBlocksCacheSettings');
            $cvbcs->addColumn('cID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 0]);
            $cvbcs->addColumn('cvID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 1]);
            $cvbcs->addColumn('bID', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 0]);
            $cvbcs->addColumn('arHandle', 'string', ['notnull' => false]);
            $cvbcs->addColumn('btCacheBlockOutput', 'boolean', ['default' => 0]);
            $cvbcs->addColumn('btCacheBlockOutputOnPost', 'boolean', ['default' => 0]);
            $cvbcs->addColumn('btCacheBlockOutputForRegisteredUsers', 'boolean', ['default' => 0]);
            $cvbcs->addColumn('btCacheBlockOutputLifetime', 'integer', ['notnull' => true, 'unsigned' => true, 'default' => 0]);
            $cvbcs->setPrimaryKey(['cID', 'cvID', 'bId', 'arHandle']);
        }
    }
752530
public function update()
    {
        // Do the initial check
        $fromTables = $this->getInstalledTables();
        $toTables = $this->getSchemaTables();
        $protectedTableNames = $this->app['schema.content_tables']->keys();

        $this->getSchemaComparator()->compare($fromTables, $toTables, $protectedTableNames, true);
        $response = $this->getSchemaComparator()->getResponse();
        $creates = $this->getSchemaComparator()->getCreates();
        $alters = $this->getSchemaComparator()->getAlters();

        $modifier = new TableModifier($this->connection, $this->app['logger.system'], $this->app['logger.flash']);
        $modifier->createTables($creates, $response);
        $modifier->alterTables($alters, $response);

        $event = new SchemaEvent($creates, $alters);
        $this->app['dispatcher']->dispatch(SchemaEvents::UPDATE, $event);

        // Recheck now that we've processed
        $fromTables = $this->getInstalledTables();
        $toTables = $this->getSchemaTables();
        $this->getSchemaComparator()->compare($fromTables, $toTables, $protectedTableNames);
        if (!$this->getSchemaComparator()->hasPending($fromTables, $toTables, $protectedTableNames)) {
            $this->getSchemaTimer()->setCheckExpiry();
        }

        return $response;
    }
751195
public function update()
    {
        //translate model data to sql data
        if (is_null($this->schema)) {
            throw Exception::forNoSchema();
        }

        $data = $this->schema->toSql();

        //queries to run
        $queries = [];
        //this is used to determine whether to add/alter/remove columns
        $exists = [];

        //if there's no system
        if (!$this->exists($data['name'])) {
            //go to create mode
            return $this->create($data, true);
        }

        $primary = $this->resource->getPrimaryKey($data['name']);
        $columns = $this->resource->getColumns($data['name']);
        $query = $this->resource->getAlterQuery($data['name']);

        //remove or change fields
        foreach ($columns as $current) {
            //don't do primary
            if ($primary === $current['Field']) {
                continue;
            }

            $exists[] = $name = $current['Field'];

            //if there is no field in the data
            if (!isset($data['columns'][$name])) {
                $query->removeField($name);
                continue;
            }

            $column = $data['columns'][$name];

            $attributes = ['type' => $column['type']];

            if (isset($column['length'])) {
                $attributes['type'] .= '(' . $column['length'] . ')';
            }

            if (isset($column['default']) && strlen($column['default'])) {
                $attributes['default'] = $column['default'];
            } else if (!isset($column['required']) || !$column['required']) {
                $attributes['null'] = true;
            }

            if (isset($column['required']) && $column['required']) {
                $attributes['null'] = false;
            }

            if (isset($column['attribute']) && $column['attribute']) {
                $attributes['attribute'] = $column['attribute'];
            }

            $default = null;
            if (isset($attributes['default'])) {
                $default = $attributes['default'];
            }

            //if all matches
            if ($attributes['type'] === $current['Type']
                && $attributes['null'] == ($current['Null'] === 'YES')
                && $default === $current['Default']
            ) {
                continue;
            }

            //do the alter
            $query->changeField($name, $attributes);
        }

        //add fields
        foreach ($data['columns'] as $name => $column) {
            if (in_array($name, $exists)) {
                continue;
            }

            $attributes = ['type' => $column['type']];

            if (isset($column['length'])) {
                $attributes['type'] .= '(' . $column['length'] . ')';
            }

            if (isset($column['default']) && strlen($column['default'])) {
                $attributes['default'] = $column['default'];
            } else if (!isset($column['required']) || !$column['required']) {
                $attributes['null'] = true;
            }

            if (isset($column['required']) && $column['required']) {
                $attributes['null'] = false;
            }

            if (isset($column['attribute']) && $column['attribute']) {
                $attributes['attribute'] = $column['attribute'];
            }

            $query->addField($name, $attributes);

            if (isset($column['index']) && $column['index']) {
                $query->addKey($name, [$name]);
            }

            if (isset($column['unique']) && $column['unique']) {
                $query->addUniqueKey($name, [$name]);
            }

            if (isset($column['primary']) && $column['primary']) {
                $query->addPrimaryKey($name);
            }
        }

        $query = (string) $query;
        if ($query !== 'ALTER TABLE `' . $data['name'] . '` ;') {
            $queries[] = $query;
        }

        $installed = $this->resource->getTables($data['name'] . '_%');
        $relations = array_keys($data['relations']);

        //determine the relation tables that need to be removed
        foreach ($installed as $relation) {
            //uninstall if it's not in the schema
            if (!in_array($relation, $relations)) {
                $queries[] = 'DROP TABLE IF EXISTS `' . $relation . '`;';
            }
        }

        //determine the relation tables that need to be added
        foreach ($data['relations'] as $table => $relation) {
            //install if it's installed
            if (in_array($table, $installed)) {
                continue;
            }

            $query = $this->resource->getCreateQuery($table);

            $query->addPrimaryKey($relation['primary1']);
            $query->addField($relation['primary1'], [
                'type' => 'int(10)',
                'null' => false,
                'attribute' => 'UNSIGNED'
            ]);

            $query->addPrimaryKey($relation['primary2']);
            $query->addField($relation['primary2'], [
                'type' => 'int(10)',
                'null' => false,
                'attribute' => 'UNSIGNED'
            ]);

            $queries[] = 'DROP TABLE IF EXISTS `'. $table . '`;';
            $queries[] = (string) $query;
        }

        //execute queries
        $results = [];
        foreach ($queries as $query) {
            $results[] = [
                'query' => $query,
                'results' => $this->resource->query($query)
            ];
        }

        return $results;
    }
1129904
protected function _mysql()
	{
		$this->_msg(sprintf('Adding label and status columns for product warehouse'), 0);
		$this->_status( '' );

		foreach ($this->_mysql as $table => $columns) {

			if ($this->_schema->tableExists($table)) {

				foreach ($columns as $column => $stmt) {

					$this->_msg(sprintf('Checking column "%1$s.%2$s": ', $table, $column), 1);

					if (!$this->_schema->columnExists($table, $column)) {
						$this->_execute($stmt);
						$this->_status('added');
					} else {
						$this->_status('OK');
					}
				}
			}
		}


		foreach ($this->_update as $table => $columns) {

			if ($this->_schema->tableExists($table)) {

				foreach ($columns as $column => $stmt) {

					$this->_msg(sprintf('Update column "%1$s.%2$s": ', $table, $column), 1);

					if ($this->_schema->columnExists($table, $column)) {
						$this->_execute($stmt);
						$this->_status('updated');
					}
				}
			}
		}

	}
1262377
public function upgradeSchema(Schema $schema)
    {
        $table = $schema->getTable('FileImageThumbnailPaths');
        if ($table->hasIndex('thumbnailPathID')) {
            $table->dropIndex('thumbnailPathID');
        }
        if (!$table->hasColumn('thumbnailFormat')) {
            $table->addColumn(
                'thumbnailFormat',
                'string',
                [
                    'notnull' => true,
                    'default' => '',
                    'length' => 5,
                ]
            );
            $table->setPrimaryKey([
                'fileID',
                'fileVersionID',
                'thumbnailTypeHandle',
                'storageLocationID',
                'thumbnailFormat',
            ]);
        }
    }
346784
public function upgrade(): void
    {
        // This table was previously created by the favorites module in 1.7.9.
        // These migrations are now part of the core code.

        if (!DB::schema()->hasTable('news')) {
            DB::schema()->create('news', static function (Blueprint $table): void {
                $table->integer('news_id', true);
                $table->integer('user_id')->nullable();
                $table->integer('gedcom_id')->nullable();
                $table->string('subject', 255);
                $table->text('body');
                $table->timestamp('updated')->useCurrent();
                
                $table->index(['user_id', 'updated']);
                $table->index(['gedcom_id', 'updated']);

                $table->foreign('user_id')->references('user_id')->on('user')->onDelete('cascade');
                $table->foreign('gedcom_id')->references('gedcom_id')->on('gedcom')->onDelete('cascade');
            });
        }
    }
168656
protected function registerDropCommand()
    {
        $this->app->singleton('command.schema.drop', function ($app) {
            return new SchemaDropCommand(
                $app['datamapper.classfinder'],
                $app['datamapper.entity.scanner'],
                $app['datamapper.schema.builder'],
                $app['datamapper.eloquent.generator'],
                $app['config']['datamapper']
            );
        });
    }
34806
public function schemaUpdate($callback)
    {
        // Begin schema update
        $this->schemaIsUpdating = true;

        // Update table list
        $this->tableList = array();
        $tables = $this->tableList();
        foreach ($tables as $table) {
            $this->tableList[strtolower($table)] = $table;
        }

        // Clear update list for client code to mess around with
        $this->schemaUpdateTransaction = array();

        /** @var Exception $error */
        $error = null;
        try {
            // Yield control to client code
            $callback();

            // If the client code has cancelled the update then abort
            if (!$this->isSchemaUpdating()) {
                return;
            }

            // End schema update
            foreach ($this->schemaUpdateTransaction as $tableName => $changes) {
                $advancedOptions = isset($changes['advancedOptions']) ? $changes['advancedOptions'] : null;
                switch ($changes['command']) {
                    case 'create':
                        $this->createTable(
                            $tableName,
                            $changes['newFields'],
                            $changes['newIndexes'],
                            $changes['options'],
                            $advancedOptions
                        );
                        break;

                    case 'alter':
                        $this->alterTable(
                            $tableName,
                            $changes['newFields'],
                            $changes['newIndexes'],
                            $changes['alteredFields'],
                            $changes['alteredIndexes'],
                            $changes['alteredOptions'],
                            $advancedOptions
                        );
                        break;
                }
            }
        } finally {
            $this->schemaUpdateTransaction = null;
            $this->schemaIsUpdating = false;
        }
    }
1212500
protected function registerMigrateRefreshCommand()
    {
        $this->app->singleton('command.module.migrate.refresh', function () {
            return new \Caffeinated\Modules\Console\Commands\ModuleMigrateRefreshCommand();
        });

        $this->commands('command.module.migrate.refresh');
    }