Change Method.

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

        $table = $this->table($tableName);
        if ($table->hasColumn('is_active')) {
            $table->changeColumn('is_active', 'boolean', [
                'default' => true,
                'null' => true,
            ]);
        }
        $table->update();
    }
404472
public function up()
	{
		if(Schema::hasColumn('001_026_field', 'field_type_026'))
		{
			// change column name
			DB::select(DB::raw('ALTER TABLE 001_026_field CHANGE field_type_026 field_type_id_026 TINYINT(3) UNSIGNED NOT NULL'));
		}

		if(Schema::hasColumn('001_026_field', 'field_type_text_026'))
		{
			// change column name
			DB::select(DB::raw('ALTER TABLE 001_026_field CHANGE field_type_text_026 field_type_name_026 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
		}

		if(Schema::hasColumn('001_026_field', 'data_type_026'))
		{
			// change column name
			DB::select(DB::raw('ALTER TABLE 001_026_field CHANGE data_type_026 data_type_id_026 TINYINT(3) UNSIGNED NOT NULL'));
		}

		if(Schema::hasColumn('001_026_field', 'data_type_text_026'))
		{
			// change column name
			DB::select(DB::raw('ALTER TABLE 001_026_field CHANGE data_type_text_026 data_type_name_026 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
		}

		if(Schema::hasColumn('001_028_field_result', 'data_type_028'))
		{
			// change column name
			DB::select(DB::raw('ALTER TABLE 001_028_field_result CHANGE data_type_028 data_type_type_028 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
		}
	}
752384
public function change() {
		$table = $this->table('queue_processes');
		$table
			->addColumn('pid', 'string', ['null' => false, 'default' => null, 'length' => 30])
			->addColumn('created', 'datetime', ['null' => true, 'default' => null])
			->addColumn('modified', 'datetime', ['null' => true, 'default' => null])
			->save();
	}
680482
public function up()
    {
        $driver = Schema::getConnection()->getDriverName();
        // Even though we take care of this scenario in the code,
        // SQL Server does not allow potential cascading loops,
        // so set the default no action and clear out created/modified by another user when deleting a user.

        $onDelete = (('sqlsrv' === $driver) ? 'no action' : 'set null');

        if (Schema::hasColumn('system_config', 'db_version')) {
            Schema::table('system_config', function (Blueprint $t) use ($onDelete) {
                // delete the old stuff and create the new config
                $t->dropPrimary('system_config_db_version_primary');
                $t->dropColumn('db_version');
                $t->dropColumn('created_date');
                $t->dropColumn('last_modified_date');
//                $t->dropColumn('created_by_id');
//                $t->dropColumn('last_modified_by_id');
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->integer('invite_email_service_id')->unsigned()->nullable();
                $t->foreign('invite_email_service_id')->references('id')->on('service')->onDelete($onDelete);
                $t->integer('invite_email_template_id')->unsigned()->nullable();
                $t->foreign('invite_email_template_id')->references('id')->on('email_template')->onDelete($onDelete);
                $t->integer('password_email_service_id')->unsigned()->nullable();
                $t->foreign('password_email_service_id')->references('id')->on('service')->onDelete($onDelete);
                $t->integer('password_email_template_id')->unsigned()->nullable();
                $t->foreign('password_email_template_id')->references('id')->on('email_template')->onDelete($onDelete);
            });
        }
    }
134188
public function up()
    {
        // We need a better way of handling data migrations...
        $system = app(System::class);
        $prefix = $system->getTablePrefix();
        DB::update("INSERT INTO {$prefix}schedules (name, message, scheduled_at, created_at, updated_at) SELECT name, message, scheduled_at, created_at, updated_at FROM {$prefix}incidents WHERE scheduled_at IS NOT NULL");

        DB::table('incidents')->whereNotNull('scheduled_at')->delete();

        Schema::table('incidents', function (Blueprint $table) {
            $table->dropColumn('scheduled_at');
        });
    }
614699
public function up()
    {
        Schema::table('theme_templates', function (Blueprint $table) {
            $table->create();
            $table->increments('id');
            $table->integer('theme_id');
            $table->integer('template_id');
            $table->string('label')->nullable();
            $table->integer('child_template')->nullable();
            $table->integer('hidden')->nullable();
            $table->timestamps();
        });

        $themeTemplates = [];
        $deleteTemplateIds = [];
        $templatesFound = [];
        $templates = DB::table('templates')->get();
        foreach ($templates as $template) {
            if (array_key_exists($template->template, $templatesFound)) {
                $deleteTemplateIds[] = $template->id;
            } else {
                $templatesFound[$template->template] = $template;
            }
            $themeTemplate = array_diff_key((array) $template, array_fill_keys(['template'], ''));
            foreach (['label', 'child_template', 'hidden'] as $attribute) {
                if ($templatesFound[$template->template]->$attribute == $themeTemplate[$attribute]) {
                    $themeTemplate[$attribute] = null;
                }
            }
            $themeTemplate['template_id'] = $templatesFound[$template->template]->id;
            $themeTemplates[] = $themeTemplate;
        }

        Schema::rename('template_blocks', 'theme_template_blocks');
        DB::table('theme_templates')->insert($themeTemplates);
        DB::table('templates')->whereIn('id', $deleteTemplateIds)->delete();
        Schema::table('templates', function(Blueprint $table) {
            $table->dropColumn('theme_id');
        });
        Schema::table('theme_template_blocks', function(Blueprint $table) {
            $table->renameColumn('template_id', 'theme_template_id');
        });
    }
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');
            });
        }
    }
216767
public function change()
    {
        $table = $this->table('roles');
        $table->addForeignKey('parent', 'roles', 'id', array('delete'=> 'SET_NULL', 'update'=> 'CASCADE'))
              ->save();

        $table = $this->table('user_roles');
        $table->addForeignKey('role', 'roles', 'id', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->addForeignKey('user', 'user', 'user', array('delete'=> 'CASCADE', 'update'=> 'CASCADE'))
              ->save();

        $table = $this->table('user');
        $table->addForeignKey('image', 'image', 'id', array('delete'=> 'RESTRICT', 'update'=> 'CASCADE'))
              ->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 . '`)');
			}
		}
	}
411407
public function up()
    {
        mb_internal_encoding("UTF-8");
        $tableOptions = $this->db->driverName === 'mysql'
            ? 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'
            : null;

        $this->createTable('{{%property}}', [
            'id' => $this->primaryKey(),
            'applicable_property_model_id' => $this->integer()->notNull(),
            'key' => $this->string(80)->notNull(),
            'data_type' => $this->boolean()->defaultValue(0),
            'is_internal' => $this->boolean()->defaultValue(0),
            'allow_multiple_values' => $this->boolean()->defaultValue(0),
            'storage_id' => $this->integer()->notNull(),
            'packed_json_default_value' => $this->text()->notNull(),
            'property_handler_id' => $this->integer()->notNull(),
//
//
//          This config can not be applied directly as handlers are singleton!
//          Therefore we need to split configs into several cases???
//
//               Or maybe it is useless
//
//            'packed_json_handler_config' => $this->text()->notNull(),
//
//
//
        ], $tableOptions);
        $this->createIndex('iKey', '{{%property}}', ['key'], true);

        $this->createTable('{{%static_value}}', [
            'id' => $this->primaryKey(),
            'property_id' => $this->integer()->notNull(),
            'sort_order' => $this->integer()->notNull()->defaultValue(0),
        ], $tableOptions);

        $this->createTable('{{%property_group}}', [
            'id' => $this->primaryKey(),
            'internal_name' => $this->string()->notNull(),
            'sort_order' => $this->integer()->notNull()->defaultValue(0),
            'applicable_property_model_id' => $this->integer()->notNull(),
            'is_auto_added' => $this->boolean()->defaultValue(0),
        ], $tableOptions);

        $this->createIndex('by_models', '{{%property_group}}', ['applicable_property_model_id']);

        $this->createTable('{{%property_property_group}}', [
            'property_id' => $this->integer()->notNull(),
            'property_group_id' => $this->integer()->notNull(),
            'sort_order_property_groups' => $this->integer()->notNull()->defaultValue(0),
            'sort_order_group_properties' => $this->integer()->notNull()->defaultValue(0),
        ], $tableOptions);

        $this->addPrimaryKey('pk', '{{%property_property_group}}', ['property_id', 'property_group_id']);

        $this->createTable('{{%property_storage}}', [
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull(),
            'class_name' => $this->string()->notNull(),
            'sort_order' => $this->integer()->notNull()->defaultValue(0),
        ], $tableOptions);

        $this->createTable(ApplicablePropertyModels::tableName(), [
            'id' => $this->primaryKey(),
            'class_name' => $this->string()->notNull(),
            'name' => $this->string()->notNull(),
        ], $tableOptions);

        $this->createTable('{{%property_handlers}}', [
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull(),
            'class_name' => $this->string()->notNull(),
            'sort_order' => $this->integer()->notNull()->defaultValue(0),
            'packed_json_default_config' => $this->text()->notNull(),
        ], $tableOptions);

        // translations
        $this->createTable('{{%property_translation}}', [
            'model_id' => $this->integer()->notNull(),
            'language_id' => $this->integer()->notNull(),
            'name' => $this->string()->notNull(),
            'description' => $this->string()->notNull()->defaultValue(''),
        ], $tableOptions);

        $this->createIndex('pk', '{{%property_translation}}', ['model_id', 'language_id'], true);
        $this->addForeignKey(
            'fkPrT',
            '{{%property_translation}}',
            ['model_id'],
            '{{%property}}',
            ['id'],
            'CASCADE'
        );

        $this->createTable('{{%static_value_translation}}', [
            'model_id' => $this->integer()->notNull(),
            'language_id' => $this->integer()->notNull(),
            'name' => $this->string()->notNull(),
            'description' => $this->string()->notNull()->defaultValue(''),
            'slug' => $this->string(80)->notNull(),
        ], $tableOptions);
        $this->createIndex('pk', '{{%static_value_translation}}', ['model_id', 'language_id'], true);
        $this->createIndex('slug', '{{%static_value_translation}}', ['slug']);
        $this->addForeignKey(
            'fkSvT',
            '{{%static_value_translation}}',
            ['model_id'],
            '{{%static_value}}',
            ['id'],
            'CASCADE'
        );

        $this->createTable('{{%property_group_translation}}', [
            'model_id' => $this->integer()->notNull(),
            'language_id' => $this->integer()->notNull(),
            'name' => $this->string()->notNull(),
        ], $tableOptions);

        $this->createIndex('pk', '{{%property_group_translation}}', ['model_id', 'language_id'], true);
        $this->addForeignKey(
            'fkPgT',
            '{{%property_group_translation}}',
            ['model_id'],
            '{{%property_group}}',
            ['id'],
            'CASCADE'
        );

        // insert default data
        $this->insert('{{%property_handlers}}', [
            'name' => 'Static values',
            'class_name' => 'DevGroup\DataStructure\propertyHandler\StaticValues',
            'sort_order' => 2,
            'packed_json_default_config' => '[]',
        ]);
        $this->insert('{{%property_handlers}}', [
            'name' => 'Text field',
            'class_name' => 'DevGroup\DataStructure\propertyHandler\TextField',
            'sort_order' => 1,
            'packed_json_default_config' => '[]',
        ]);

        $this->insert('{{%property_storage}}', [
            'name' => 'Static values',
            'class_name' => 'DevGroup\DataStructure\propertyStorage\StaticValues',
            'sort_order' => 2,
        ]);
        $this->insert('{{%property_storage}}', [
            'name' => 'EAV',
            'class_name' => 'DevGroup\DataStructure\propertyStorage\EAV',
            'sort_order' => 1,
        ]);
        $this->insert('{{%property_storage}}', [
            'name' => 'Table Inheritance',
            'class_name' => 'DevGroup\DataStructure\propertyStorage\TableInheritance',
            'sort_order' => 3,
        ]);
    }
1205771
public function up()
    {
        Schema::table('hc_resource_grab_property', function (Blueprint $table) {
            $table->string('width')->default('0');
            $table->string('height')->default('0');
            $table->string('x')->change();
            $table->string('y')->change();
        });
    }
1018413
public function up()
	{
        // Add column "active" if NOT exist
        if (!Schema::hasColumn('pricelists', 'active')) {
            Schema::table('pricelists', function(Blueprint $table)
            {
                $table->boolean('active')->default(true);
            });
        }
	}
887006
public function change()
    {
        $table = $this->table('menus');
        $table->addColumn('default', 'boolean', [
            'default' => null,
            'null' => true,
        ]);
        $table->update();
    }
945587
public function migrate()
	{
		$table = 'fe_users';
		$column = 'siteid';

		$this->msg( sprintf( 'Adding "%1$s" column to "%2$s" table', $column, $table ), 0 );

		$schema = $this->getSchema( 'db-customer' );

		if( isset( $this->migrate[$schema->getName()] )
			&& $schema->tableExists( $table ) === true
			&& $schema->columnExists( $table, $column ) === false )
		{
			foreach ( $this->migrate[$schema->getName()] as $stmt )
			{
				$this->execute( $stmt );
			}
			$this->status( 'done' );
		}
		else
		{
			$this->status( 'OK' );
		}
	}
506205
public function up()
    {
        Schema::create('settings', function (Blueprint $table) {

            $table->increments('id');
            $table->string('module_name', 30);
            $table->enum('action', ['setting', 'xfield', 'creat', 'edit'])->default('setting');
            $table->string('section', 20)->default('main');
            $table->string('fieldset', 20)->default('general');
            $table->string('name', 30);
            $table->string('type', 20)->default('string');
            $table->string('value');
            $table->text('params')->nullable(); // multiline or json, or dinamic values
            $table->text('class')->length(255)->nullable();
            $table->text('html_flags')->length(500)->nullable();
            $table->string('title', 125)->nullable();
            $table->text('descr')->length(500)->nullable();

            // If need to monitor an additional field. I.e.: create and delete him.
            $table->boolean('as_xfield')->nullable();

            $table->index('action');
            $table->index('module_name');
            $table->unique(['name', 'module_name']);
            // $table->foreign('module_id', DB::getTablePrefix() . 'settings_module_id_fk')->references('id')->on('modules')
            $table->foreign('module_name')->references('name')->on('modules')
                  ->onDelete('cascade')->onUpdate('cascade');

            $table->timestamps();
        });
    }
814533
public function up()
    {
        Schema::create('content_elements', function (Blueprint $table) {
            $table->increments('id');
            $table->string('type', 20)->nullable();
            $table->string('html')->nullable()->default(null);
            $table->string('html_tag')->nullable()->default(null);
            $table->enum('wrapper_type', ['begin', 'end'])->nullable()->default(null);
            $table->string('label')->nullable()->default(null);
            $table->string('form_input_type', 20)->nullable()->default(null);
            $table->text('html_attributes')->nullable()->default(null);
            $table->text('form_options')->nullable()->default(null);
            $table->string('form_validation')->nullable()->default('string');

            $table->nullableTimestamps();
        });
    }
968668
public function up()
    {
        Schema::table('notifications', function ($table) {
            $driver = Config::get('database.driver');

            if ($driver === 'mysql' || $driver === 'sqlite') {
                DB::statement('ALTER TABLE notifications MODIFY COLUMN extra json');
            } elseif ($driver === 'pgsql') {
                DB::statement('ALTER TABLE notifications ALTER COLUMN extra TYPE json USING code::string');
            }
        });
    }