Change Method.

More information on this method is available here:
http://docs.phinx.org/en/latest/migrations.html#the-change-method
@return void
962086
public function change()
    {
        $tableName = 'language_translations';
        if (!$this->hasTable($tableName)) {
            $tableName = 'translations';
        }

        $table = $this->table($tableName);
        if ($table->hasColumn('created')) {
            $table->changeColumn('created', 'datetime', [
                'default' => null,
                'null' => true
            ]);
        }
        if ($table->hasColumn('modified')) {
            $table->changeColumn('modified', 'datetime', [
                'default' => null,
                'null' => true
            ]);
        }
        $table->save();
    }
1118034
public function up() {
		$db = Database::get();

		$database = $db->get_one('SELECT DATABASE()');

		$indexes = ['completed', 'frozen', 'failed'];

		foreach ($indexes as $index) {
			if ($db->get_one('SELECT 1 FROM INFORMATION_SCHEMA.STATISTICS WHERE 1 AND TABLE_SCHEMA = "' . $database . '" AND TABLE_NAME="transaction" AND INDEX_NAME="' . $index . '"') === null) {
				$db->query('ALTER TABLE `transaction` ADD INDEX `' . $index . '` (`' . $index . '`)');
			}
		}
	}
199000
public function change()
    {
        $permissionTable = $this->table('permission', ['signed' => false]);

        $permissionTable->addColumn('name', 'string', ['limit' => 100])
            ->addColumn('status', 'boolean', ['default' => 1])
            ->addColumn('created_at', 'datetime')
            ->addColumn('updated_at', 'datetime', ['null' => true])
            ->addIndex('name', ['name' => 'idx_role_name' ,'unique' => true])
            ->create();
    }
755736
private function replaceAttributesWithChange()
    {
        if (($change = static::lookupRequestedChange())
            && $change->key == $this->getKey()) {
            $this->attributes = array_merge(
                $this->attributes,
                $this->attributesAtChange($change)
            );
        }
    }
1103703
public function up()
    {
        Schema::table('notifications', function (Blueprint $table) {
            $table->bigInteger('from_id')->unsigned()->nullable()->change();
        });
        Schema::table('notifications', function (Blueprint $table) {
            $table->renameColumn('expire_time', 'expires_at');
        });
    }
396888
public function up()
    {
        Schema::table('email_log', function ($table) {
            if (!Schema::hasColumn('email_log', 'id')) {
                $table->increments('id')->first();
                $table->string('from')->after('date')->nullable();
                $table->string('cc')->after('to')->nullable();
                $table->text('headers')->after('body')->nullable();
                $table->text('attachments')->after('headers')->nullable();
            }
        });
    }
1351003
public function up()
    {
        $this->table('phinxlog')
            ->addColumn('version', 'integer', [
                'limit'  => 11,
                'null'   => false,
                'signed' => false
            ])
            ->addColumn('migration_name', 'string', [
                'limit'   => 100,
                'default' => null,
                'null'    => true
            ])
            ->addColumn('start_time', 'datetime', [
                'limit'   => null,
                'null'    => true,
                'default' => 'CURRENT_TIMESTAMP'
            ])
            ->addColumn('end_time', 'datetime', [
                'limit'   => null,
                'null'    => true,
                'default' => 'CURRENT_TIMESTAMP'
            ])
            ->addColumn('breakpoint', 'boolean', [
                'limit'   => null,
                'default' => false,
                'null'    => false
            ]);

        $this->table('extensions')
            ->addColumn('id', 'integer', [
                'limit'         => 11,
                'autoIncrement' => true,
                'default'       => null,
                'null'          => false,
                'signed'        => false
            ])
            ->addPrimaryKey([
                'id'
            ])
            ->addColumn('name', 'string', [
                'limit'   => 150,
                'default' => null,
                'null'    => false
            ])
            ->addColumn('type', 'string', [
                'limit'   => 20,
                'default' => null,
                'null'    => false
            ])
            ->addColumn('ordering', 'integer', [
                'default' => 0,
                'limit'   => 11,
                'null'    => false
            ])
            ->addColumn('slug', 'string', [
                'limit'   => 150,
                'default' => null,
                'null'    => false
            ])
            ->addColumn('core', 'boolean', [
                'limit'   => null,
                'default' => false,
                'null'    => false
            ])
            ->addColumn('status', 'boolean', [
                'limit'   => null,
                'default' => false,
                'null'    => false
            ])
            ->addColumn('params', 'text', [
                'default' => null,
                'limit'   => null,
                'null'    => true
            ])
            ->create();

        // TODO: Write default loaded plugins.
    }
701399
public function change()
    {
        $table = $this->table('calendar_events');
        $hasSource = $table->hasColumn('event_source');
        $hasSourceId = $table->hasColumn('event_source_id');

        if ($hasSource) {
            $table->renameColumn('event_source', 'source');
        }

        if ($hasSourceId) {
            $table->renameColumn('event_source_id', 'source_id');
        }
    }
70146
public function change() {
		$this->table('queue_processes')
			->addColumn('workerkey', 'string', [
				'length' => 45,
				'null' => false,
				'default' => null,
				'encoding' => 'utf8mb4',
				'collation' => 'utf8mb4_unicode_ci',
			])
			->save();

		$this->table('queue_processes')
			->addIndex(['workerkey'], ['unique' => true])
			->save();
	}
1287733
public function up()
	{
		try {
			DB::statement("ALTER TABLE  `" . $this->getLogTable() . "` drop foreign key transactions_logs_transaction_id_foreign;");
			DB::statement("ALTER TABLE  `" . $this->getLogTable() . "` DROP INDEX transactions_logs_transaction_id_foreign;");
		} catch (Exception $e) {
			
		}	
		
		try {		
			DB::statement("update `" . $this->getTable() . "` set `payment_date`=null WHERE  `payment_date`=0;");
			DB::statement("ALTER TABLE `" . $this->getTable() . "` CHANGE `id` `id` BIGINT UNSIGNED NOT NULL;");
			DB::statement("ALTER TABLE `" . $this->getLogTable() . "` CHANGE `transaction_id` `transaction_id` BIGINT UNSIGNED NOT NULL;");
			DB::statement("ALTER TABLE  `" . $this->getLogTable() . "` ADD INDEX `transactions_logs_transaction_id_foreign` (`transaction_id`);");
		} catch (Exception $e) {
			
		}
	}
744317
private function createChange() : Change
    {
        $changeClass = '\\CaptainHook\\App\\Runner\\Config\\Change\\' . $this->change;
        if (!class_exists($changeClass)) {
            throw new \RuntimeException('Invalid change requested');
        }

        return new $changeClass($this->io, $this->hookToEdit);
    }
1001469
public function up()
    {
        Schema::table('attributes', function (Blueprint $table) {

            // String settings
            $table->integer('maxlength')->nullable();
            $table->string('pattern')->nullable();
            $table->string('autocomplete')->nullable();
            $table->string('placeholder')->nullable();

            // Numeric settings
            $table->double('min')->nullable();
            $table->double('max')->nullable();
            $table->double('step')->nullable();
        });
    }
688669
public function up()
    {
        Schema::table('email_log', function ($table) {
            if (!Schema::hasColumn('email_log', 'bcc')) {
                $table->string('to')->nullable()->change();
                $table->string('bcc')->after('to')->nullable();
            }
        });
    }
537493
public function migrateUp()
    {
        try {
            $this->builder->table(
                $this->table,
                function ($table) {
                    $table->string('value')->nullable()->change();
                }
            );
        } catch (\Exception $e) {
            dd($e->getMessage());
        }
    }
1210903
public function up()
    {
        Schema::table('user_settings', function (Blueprint $table) {
            $table->integer('value')->nullable()->comment = "value set by user";
            $table->timestamp('set_at')->nullable();
        });
    }
1046276
public function applyChanges(array $changes): void
    {
        /* @var $change TableChange */
        foreach ($changes as $change) {
            if (!$change instanceof TableChange) {
                throw new InvalidArgumentException('You must provide array of TableChange objects.');
            }

            switch ($change->method) {
                case 'createTable':
                    /* @var $column TableColumn */
                    foreach ($change->value as $column) {
                        $this->columns[$column->name] = $column;

                        if ($column->isPrimaryKey || $column->isColumnAppendPK()) {
                            if ($this->primaryKey === null) {
                                $this->primaryKey = new TablePrimaryKey(['columns' => [$column->name]]);
                            } else {
                                $this->primaryKey->addColumn($column->name);
                            }
                        }
                    }
                    break;

                case 'addColumn':
                    $this->columns[$change->value->name] = $change->value;

                    if ($change->value->isPrimaryKey || $change->value->isColumnAppendPK()) {
                        if ($this->primaryKey === null) {
                            $this->primaryKey = new TablePrimaryKey(['columns' => [$change->value->name]]);
                        } else {
                            $this->primaryKey->addColumn($change->value->name);
                        }
                    }
                    break;

                case 'dropColumn':
                    unset($this->columns[$change->value]);
                    break;

                case 'renameColumn':
                    if (isset($this->columns[$change->value['old']])) {
                        $this->columns[$change->value['new']] = $this->columns[$change->value['old']];
                        $this->columns[$change->value['new']]->name = $change->value['new'];

                        unset($this->columns[$change->value['old']]);
                    }
                    break;

                case 'alterColumn':
                    $this->columns[$change->value->name] = $change->value;
                    break;

                case 'addPrimaryKey':
                    $this->primaryKey = $change->value;

                    foreach ($this->primaryKey->columns as $column) {
                        if (isset($this->columns[$column])) {
                            if (empty($this->columns[$column]->append)) {
                                $this->columns[$column]->append = $this->columns[$column]->prepareSchemaAppend(true, false);
                            } elseif (!$this->columns[$column]->isColumnAppendPK()) {
                                $this->columns[$column]->append .= ' ' . $this->columns[$column]->prepareSchemaAppend(true, false);
                            }
                        }
                    }
                    break;

                case 'dropPrimaryKey':
                    if ($this->primaryKey !== null) {
                        foreach ($this->primaryKey->columns as $column) {
                            if (isset($this->columns[$column]) && !empty($this->columns[$column]->append)) {
                                $this->columns[$column]->append = $this->columns[$column]->removePKAppend();
                            }
                        }
                    }

                    $this->primaryKey = null;
                    break;

                case 'addForeignKey':
                    $this->foreignKeys[$change->value->name] = $change->value;
                    break;

                case 'dropForeignKey':
                    unset($this->foreignKeys[$change->value]);
                    break;

                case 'createIndex':
                    $this->indexes[$change->value->name] = $change->value;
                    if (
                        $change->value->unique
                        && isset($this->columns[$change->value->columns[0]])
                        && count($change->value->columns) === 1
                    ) {
                        $this->columns[$change->value->columns[0]]->isUnique = true;
                    }
                    break;

                case 'dropIndex':
                    if (
                        $this->indexes[$change->value]->unique
                        && count($this->indexes[$change->value]->columns) === 1
                        && isset($this->columns[$this->indexes[$change->value]->columns[0]])
                        && $this->columns[$this->indexes[$change->value]->columns[0]]->isUnique
                    ) {
                        $this->columns[$this->indexes[$change->value]->columns[0]]->isUnique = false;
                    }
                    unset($this->indexes[$change->value]);
                    break;

                case 'addCommentOnColumn':
                    if (isset($this->columns[$change->value->name])) {
                        $this->columns[$change->value->name]->comment = $change->value->comment;
                    }
                    break;

                case 'dropCommentFromColumn':
                    if (isset($this->columns[$change->value])) {
                        $this->columns[$change->value]->comment = null;
                    }
            }
        }
    }
234848
public function change()
    {
        $table = $this->table('permissions');
        
        $table->addColumn('owner_model', 'string', [
            'default' => null,
            'null' => false,
            'limit' => 50,
        ]);

        $table->removeColumn('user_id');
        $table->removeColumn('is_active');

        $table->addColumn('owner_foreign_key', 'char', [
            'default' => null,
            'null' => false,
            'limit' => 36 
        ]);

        $table->save();
    }