Change Method.

Write your reversible migrations using this method.

More information on writing migrations is available here:
http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class

@return void
964908
public function change() {
		if ($this->table('queue_processes')->hasIndex(['pid'], ['unique' => true])) {
			$this->table('queue_processes')
				->removeIndex(['pid'], ['unique' => true])
				->save();
		}

		$this->table('queue_processes')
			->addIndex(['pid', 'server'], ['unique' => true])
			->save();
	}
279776
public static function rollback()
    {
        foreach (array_reverse(self::$migrationClasses) as $migrationClass) {
            /** @var Migration $instance */
            $instance = new $migrationClass;
            $instance->rollback();
        }
    }
524029
public function change()
    {
        $table = $this->table('dashboards');
        $table->changeColumn('name', 'string', [
            'default' => null,
            'limit' => 255,
            'null' => false,
        ]);
        $table->update();
    }
385432
public function 
    {

        $count = $this->count();

        foreach ($this->migrations as $i => $mig) {
            if ($this->preCallback) {
                $callback = $this->preCallback;
                $callback($mig->getVersion(), $i, $count);
            }

            if ($this->direction == 'up') {
                $mig->up();
            } elseif ($this->direction == 'down') {
                $mig->down();
            }

            if ($this->postCallback) {
                $callback = $this->postCallback;
                $callback($mig->getVersion(), $i, $count);
            }
        }
    }
935909
public function migrateUp()
    {
        $this->builder->table(
            $this->table,
            function ($table) {
                $table->integer('referer_id')->unsigned()->nullable()->index();
            }
        );
    }
465721
public function up()
    {
        Schema::table('forum_categories', function (Blueprint $table)
        {
            $table->renameColumn('parent_category', 'category_id');
            $table->renameColumn('subtitle', 'description');
        });

        Schema::table('forum_categories', function (Blueprint $table)
        {
            $table->integer('category_id')->default(0)->change();
            $table->string('description')->nullable()->change();
            $table->integer('weight')->default(0)->change();

            $table->boolean('enable_threads')->default(0);
            $table->boolean('private')->default(0);

            $table->timestamps();
        });
    }
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);
            });
        }
	}
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.
    }
621734
public function up()
    {
        if (Schema::hasColumn('system_config', 'login_with_user_name')) {
            if ('sqlsrv' == DB::connection()->getDriverName()) {
                $defaultContraint = DB::selectOne("SELECT OBJECT_NAME([default_object_id]) AS name FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID('[dbo].[system_config]') AND [name] = 'login_with_user_name'");
                DB::statement("ALTER TABLE [dbo].[system_config] DROP CONSTRAINT $defaultContraint->name");
            }

            Schema::table('system_config', function (Blueprint $t) {
                $t->dropColumn('login_with_user_name');
            });
        }
    }
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'));
		}
	}
540360
public function up()
    {
        Schema::create('mc_conversations', function (Blueprint $table) {
            $table->increments('id');
            $table->boolean('private')->default(true);
            $table->text('data')->nullable();
            $table->timestamps();
        });

        Schema::create('mc_messages', function (Blueprint $table) {
            $table->increments('id');
            $table->text('body');
            $table->integer('conversation_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->string('type')->default('text');
            $table->timestamps();

            $table->foreign('user_id')
                ->references($this->userModelPrimaryKey)
                ->on($this->userModelTable)
                ->onDelete('cascade');

            $table->foreign('conversation_id')
                ->references('id')
                ->on('mc_conversations')
                ->onDelete('cascade');
        });

        Schema::create('mc_conversation_user', function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->integer('conversation_id')->unsigned();
            $table->primary(['user_id', 'conversation_id']);
            $table->timestamps();

            $table->foreign('conversation_id')
                ->references('id')->on('mc_conversations')
                ->onDelete('cascade');

            $table->foreign('user_id')
                ->references($this->userModelPrimaryKey)
                ->on($this->userModelTable)
                ->onDelete('cascade');
        });

        Schema::create('mc_message_notification', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('message_id')->unsigned();
            $table->integer('conversation_id')->unsigned();
            $table->integer('user_id')->unsigned();
            $table->boolean('is_seen')->default(false);
            $table->boolean('is_sender')->default(false);
            $table->boolean('flagged')->default(false);
            $table->timestamps();
            $table->softDeletes();

            $table->index(['user_id', 'message_id']);

            $table->foreign('message_id')
                ->references('id')->on('mc_messages')
                ->onDelete('cascade');

            $table->foreign('conversation_id')
                ->references('id')->on('mc_conversations')
                ->onDelete('cascade');

            $table->foreign('user_id')
                ->references($this->userModelPrimaryKey)
                ->on($this->userModelTable)
                ->onDelete('cascade');
        });
    }
1107875
public function up()
    {
        $table = $this->table('users');

        if (!$table->hasColumn('firstname')) {
            $table->addColumn('firstname', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'after' => 'language_id']);
        }

        if (!$table->hasColumn('lastname')) {
            $table->addColumn('lastname', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'after' => 'firstname']);
        }

        $table->update();

        $this->clearModelCache();
    }
1200648
public function change() {
		$this->table('queue_processes')
			->changeColumn('created', 'datetime', ['null' => false, 'default' => null])
			->changeColumn('modified', 'datetime', ['null' => false, 'default' => null])
			->update();

		$this->table('queued_jobs')
			->changeColumn('created', 'datetime', ['null' => false, 'default' => null])
			->update();
	}
1346427
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');

        $output = new ConsoleOutput();
        $output->writeln("Migration driver used: $driver");

        // Script Service Config
        if (!Schema::hasTable('script_config')) {
            Schema::create(
                'script_config',
                function (Blueprint $t) {
                    $t->integer('service_id')->unsigned()->primary();
                    $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                    $t->mediumText('content')->nullable();
                    $t->text('config')->nullable();
                }
            );
        }

        // Event Scripts
        if (!Schema::hasTable('event_script')) {
            Schema::create(
                'event_script',
                function (Blueprint $t) use ($onDelete) {
                    $t->string('name', 80)->primary();
                    $t->string('type', 40);
                    $t->boolean('is_active')->default(0);
                    $t->mediumText('content')->nullable();
                    $t->text('config')->nullable();
                    $t->timestamp('created_date')->nullable();
                    $t->timestamp('last_modified_date')->useCurrent();
                    $t->integer('created_by_id')->unsigned()->nullable();
                    $t->foreign('created_by_id')->references('id')->on('user')->onDelete($onDelete);
                    $t->integer('last_modified_by_id')->unsigned()->nullable();
                    $t->foreign('last_modified_by_id')->references('id')->on('user')->onDelete($onDelete);
                }
            );
        }
    }
193830
protected function migrateTeachers()
    {
        $this->output->info('### Migrating teachers ###');
        foreach ($this->teachers() as $teacher) {
            $this->showMigratingInfo($teacher, 1);
            $this->output->info('  email: ' . $teacher->email);
            $this->migrateTeacher($teacher);
        }
        $this->output->info(
            '### END Migrating teachers. Migrated ' . count($this->teachers()) .  ' teachers   ###');
    }
451658
public function change() {
		$table = $this->table('queued_tasks');

		$table->changeColumn('status', 'string', [
		    'length' => 255,
			'null' => true,
			'default' => null,
		]);

		$table->save();
	}
841502
public function change()
    {
        $table = $this->table('calendar_events');
        $table->addIndex(['calendar_id']);
        $table->addIndex(['is_recurring']);
        $table->addIndex(['start_date']);
        $table->addIndex(['end_date']);
        $table->update();
    }