(non-PHPdoc)
@see \Doctrine\DBAL\Migrations\AbstractMigration::up()
178084
public function up(Schema $schema)
    {
        // copy images for example items
        $this->fs->mirror($this->source, $this->target);

        // create storage
        $storage = (new Storage())
            ->setDescription('Storage on local computer')
            ->setName('Local')
            ->setPath(Filesystem::getUserHomeDir())
            ->setType(Storage::TYPE_FOLDER);
        $this->em->persist($storage);

        // create items
        $this->persist($this->getItemOnePiece($storage));
        $this->persist($this->getItemFullmetalAlchemist($storage));
        $this->persist($this->getItemSpiritedAway($storage));
        $this->em->flush();
    }
450656
public function up()
    {

        if (!Schema::hasTable('reg2005_accounts')) {
            //
            Schema::create('reg2005_accounts', function (Blueprint $table) {
                $table->increments('id');
                $table->text('login')->nullable();
                $table->text('password')->nullable();
                $table->text('protocol')->nullable();
                $table->text('address')->nullable();

                $table->decimal('USD', 10)->nullable()->default(0);
                $table->decimal('RUB', 10)->nullable()->default(0);
                $table->decimal('BTC', 14, 8)->nullable()->default(0);
                $table->decimal('EUR', 10)->nullable()->default(0);
                $table->decimal('KZT', 10)->nullable()->default(0);
                $table->decimal('GOLD', 10)->nullable()->default(0);

                $table->decimal('in_turnover_current_monthly', 10)->nullable()->default(0);
                $table->decimal('out_turnover_current_monthly', 10)->nullable()->default(0);

                $table->integer('no_active')->default(0);
                $table->integer('error_out_pays')->default(0);
                $table->text('type')->nullable();
                $table->text('site')->nullable();

                $table->integer('upd_history')->nullable()->default(0);

                $table->timestamp('last_history')->default('2016-01-01 00:00:00');
                $table->timestamp('last_use')->default(DB::raw('CURRENT_TIMESTAMP'));
                $table->timestamps();
            });

        }
    }
1038341
private function up($id)
    {
        /* @var Gallery_Entity_Table_Image $table */
        $table = ORM::getTable($this, 'Image');
        /* @var Gallery_Entity_Image $image */
        $image = $table->find($id);
        $table->moveUp($image);
        HTTP::goback();
    }
248954
public function up()
	{
		if(! Schema::hasColumn('001_027_field_value', 'counter_027'))
		{
			Schema::table('001_027_field_value', function (Blueprint $table) {

				// delete primary keys
				Schema::table('001_027_field_value', function (Blueprint $table) {
					$table->dropPrimary('PRIMARY');
				});

				// change id to string value
				DB::select(DB::raw('ALTER TABLE 001_027_field_value CHANGE id_027 id_027 VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));

				// set primary key
				$table->primary(['id_027', 'lang_027', 'field_027'], 'pk01_001_027_field_value');

				// create counter column
				$table->integer('counter_027')->unsigned()->nullable()->after('field_027');
			});
		}

        if(Schema::hasColumn('001_027_field_value', 'value_027'))
        {
            // change column value_027 to name_027
            DB::select(DB::raw('ALTER TABLE 001_027_field_value CHANGE value_027 name_027 VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
        }
	}
2109
public function up()
    {
        $table = file_get_contents(dirname(__FILE__) . '/media.sql');
        return $this->db->createCommand($table)->execute();
    }
523483
public function up()
    {
        //legacy app clean up
        dbexec('DELETE FROM `#__migrator_versions` WHERE component = "opensocial"');

        dbexec('ALTER TABLE `#__nodes` CHANGE `meta` `meta` text DEFAULT NULL');
        dbexec('ALTER TABLE `#__edges` CHANGE `meta` `meta` text DEFAULT NULL');
        dbexec('ALTER TABLE `#__components` CHANGE `params` `meta` text DEFAULT NULL');
        dbexec('ALTER TABLE `#__components` DROP COLUMN `link`');
        dbexec('ALTER TABLE `#__components` DROP COLUMN `menuid`');
        dbexec('ALTER TABLE `#__components` DROP COLUMN `admin_menu_link`');
        dbexec('ALTER TABLE `#__components` DROP COLUMN `admin_menu_alt`');
        dbexec('ALTER TABLE `#__components` DROP COLUMN `admin_menu_img`');

        //deleting legacy data
        dbexec('DELETE FROM `#__components` WHERE `option` IN ("com_config","com_cpanel","com_plugins","com_templates","com_components", "com_languages")');

        $this->_updateMeta('components');

        dbexec('UPDATE `#__components` SET meta = REPLACE(meta, \'"allowUserRegistration":\', \'"allow_registration":\') WHERE `option` = \'com_people\'');

        //legacy data clean up
        dbexec('DELETE FROM `#__plugins` WHERE `element` = "invite" ');
        dbexec('ALTER TABLE `#__plugins` DROP COLUMN `access`');
        dbexec('ALTER TABLE `#__plugins` DROP COLUMN `client_id`');
        dbexec('ALTER TABLE `#__plugins` DROP COLUMN `checked_out`');
        dbexec('ALTER TABLE `#__plugins` DROP COLUMN `checked_out_time`');

        $this->_updateMeta('plugins');

        dbexec('DROP TABLE IF EXISTS `#__templates_menu`');
        dbexec('DROP TABLE IF EXISTS `#__session`');
        dbexec('DROP TABLE IF EXISTS `#__sessions`');

        $query = "CREATE TABLE `#__sessions` ("
        ."`id` SERIAL,"
        ."`session_id` char(64) NOT NULL,"
        ."`node_id` bigint(11) NOT NULL DEFAULT 0,"
        ."`username` varchar(255) DEFAULT NULL,"
        ."`usertype` varchar(255),"
        ."`time` INT(11) DEFAULT 0,"
        ."`guest` tinyint(2) DEFAULT '1',"
        ."`meta` longtext,"
        ."PRIMARY KEY (`id`),"
        ."KEY `whosonline` (`guest`,`usertype`,`username`),"
        ."UNIQUE KEY `session_id` (`session_id`),"
        ."KEY `node_id` (`node_id`),"
        ."KEY `username` (`username`)"
        .") ENGINE=InnoDB CHARACTER SET=utf8";
        dbexec($query);

        //for people the alias is the same as username
        dbexec("UPDATE `#__nodes` SET alias = person_username WHERE type LIKE '%com:people.domain.entity.person' ");

        dbexec('DROP TABLE IF EXISTS `#__people_people`');

        $query = "CREATE TABLE `#__people_people` ("
        ."`people_person_id` SERIAL,"
        ."`node_id` BIGINT UNSIGNED NOT NULL,"
        ."`userid` INT(11) DEFAULT NULL,"
        ."`email` varchar(255) DEFAULT NULL,"
        ."`username` varchar(255) DEFAULT NULL,"
        ."`password` varchar(255) DEFAULT NULL,"
        ."`usertype` varchar(50) DEFAULT NULL,"
        ."`gender` varchar(50) DEFAULT NULL,"
        ."`given_name` varchar(255) DEFAULT NULL,"
        ."`family_name` varchar(255) DEFAULT NULL,"
        ."`network_presence` tinyint(3) NOT NULL DEFAULT 0,"
        ."`last_visit_date` datetime DEFAULT NULL,"
        ."`time_zone` int(11) DEFAULT NULL,"
        ."`language` varchar(100) DEFAULT NULL,"
        ."`activation_code` varchar(255) DEFAULT NULL,"
        ."PRIMARY KEY (`people_person_id`),"
        ."KEY `usertype` (`usertype`),"
        ."UNIQUE KEY `username` (`username`),"
        ."UNIQUE KEY `email` (`email`),"
        ."UNIQUE KEY `node_id` (`node_id`),"
        ."KEY `last_visit_date` (`last_visit_date`)"
        .") ENGINE=InnoDB CHARACTER SET=utf8";
        dbexec($query);

        $query = "INSERT INTO `#__people_people` ("
        ."`node_id`,`userid`,`username`,`usertype`,`gender`,"
        ."`email`,`given_name`,`family_name`,"
        ."`last_visit_date`,`time_zone`,`language` )"
        ." SELECT "
        ."`id`,`person_userid`,`person_username`,`person_usertype`,`actor_gender`,"
        ."`person_useremail`,`person_given_name`,`person_family_name`,"
        ."`person_lastvisitdate`,`person_time_zone`,`person_language` "
        ." FROM `#__nodes`"
        ." WHERE `type` LIKE '%com:people.domain.entity.person'"
        ." ORDER BY `id`";
        dbexec($query);

        $query = "UPDATE `#__people_people` AS `p` "
        ."INNER JOIN `#__users` AS `u` ON `u`.`id` = `p`.`userid`"
        ." SET "
        ."`p`.`password` = `u`.`password`,"
        ."`p`.`last_visit_date` = `u`.`lastvisitDate`,"
        ."`p`.`activation_code` = `u`.`activation`";
        dbexec($query);

        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_userid`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_username`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_useremail`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_usertype`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_lastvisitdate`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `actor_gender`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_given_name`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_family_name`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `person_network_presence`');

        dbexec('ALTER TABLE `#__nodes` CHANGE `person_time_zone` `timezone` int(3) DEFAULT NULL');
        dbexec('ALTER TABLE `#__nodes` CHANGE `person_language` `language` VARCHAR(50) DEFAULT NULL');

        dbexec('ALTER TABLE `#__people_people` DROP COLUMN `userid`');

        dbexec('DROP TABLE IF EXISTS `#__users`');

        //update user and authentication plugins
        dbexec("UPDATE `#__plugins` SET `element` = 'anahita' WHERE `element` = 'joomla'");
        dbexec("UPDATE `#__plugins` SET `name` = 'User - Anahita' WHERE `folder` = 'user' AND `element` = 'anahita'");

        dbexec('ALTER TABLE `#__nodes` CHANGE name name VARCHAR(255) CHARACTER SET utf8mb4');
        dbexec('ALTER TABLE `#__nodes` CHANGE alias alias VARCHAR(255) CHARACTER SET utf8mb4');
        dbexec('ALTER TABLE `#__nodes` CHANGE body body MEDIUMTEXT CHARACTER SET utf8mb4');
        dbexec('ALTER TABLE `#__nodes` CHANGE excerpt excerpt TEXT CHARACTER SET utf8mb4');
    }
612261
public function up()
    {
        Schema::create('categories', function (Blueprint $table) {

            $table->increments('id');
            $table->integer('image_id')->unsigned()->nullable();
            $table->unsignedInteger('parent_id')->default(0);
            $table->unsignedInteger('position')->length(10)->nullable();

            $table->string('title')->unique();
            $table->string('slug')->unique();
            $table->string('alt_url')->nullable();
            $table->string('description')->nullable();
            $table->string('keywords')->nullable();
            $table->text('info')->length(500)->nullable();

            $table->boolean('show_in_menu')->nullable()->default('1');

            $table->unsignedTinyInteger('paginate')->nullable();
            $table->string('order_by', 30)->nullable();
            $table->enum('direction', ['desc', 'asc'])->default('desc');

            $table->string('template', 20)->nullable();

            $table->index('parent_id');
            $table->index('position');
            $table->foreign('image_id')->references('id')->on('files')->onDelete('set null');

            $table->timestamps();
        });

    }
1091274
public function up()
    {
        // CAUTION: only works and tested on MySQL
        // Legacy support, default type MyISAM doesn't support foreign key
        // Convert table to InnoDB
        if (Schema::hasTable('products')) {
            DB::statement('ALTER TABLE products ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('categories')) {
            DB::statement('ALTER TABLE categories ENGINE = InnoDB');
        }

        if (Schema::hasTable('pricelists')) {
            DB::statement('ALTER TABLE pricelists ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('medias')) {
            DB::statement('ALTER TABLE medias ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('modules')) {
            DB::statement('ALTER TABLE modules ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('memberships')) {
            DB::statement('ALTER TABLE memberships ENGINE = InnoDB');
        }
        
        if (Schema::hasTable('coupons')) {
            DB::statement('ALTER TABLE coupons ENGINE = InnoDB');
        }
    }
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);
                }
            );
        }
    }
802059
public function up ()
		{
			$this->createTable('setting', [
				'name'        => $this->string(45)->notNull()->unique(),
				'value'       => $this->text()->null(),
				'description' => $this->text()->null(),
			]);
			$this->addPrimaryKey('name', 'setting', 'name');
		}
498246
public function up()
    {
        if ($this->hasTable('users_groups')) {
            return;
        }

        $table = $this->table('users_groups');
        $table->addColumn('user_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => false])
            ->addColumn('group_id', 'integer', ['limit' => 11, 'signed' => false, 'null' => false]);
        $table->addIndex('user_id', ['name' => 'FK_USER_ID', 'unique' => false])
            ->addIndex('group_id', ['name' => 'FK_GROUP_ID', 'unique' => false]);
        $table->create();

        $this->unsignedIntId($table);
        $table->save();

        $UsersGroups = \Cake\ORM\TableRegistry::get('UsersGroups');
        $UsersGroups->save($UsersGroups->newEntity([
            'user_id' => 1,
            'group_id' => 1
        ]));
    }
1116833
public static function migrateUp()
    {
        $migration = new Migration(Yii::getAlias('@vendor/colibri-platform/admin/migrations'));
        $migration->up();

        return implode("\n", $migration->messages);
    }
754312
public function up()
    {
        Schema::create($this->prefixCmsTable('file_uploads'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('reference', 191)->nullable()->index();
            $table->string('name', 191)->nullable();
            $table->text('path')->nullable();
            $table->string('uploader', 191)->nullable();
            $table->integer('file_size')->unsigned()->nullable();
            $table->nullableTimestamps();
        });
    }
755140
public function up()
    {
        // Check if the table exists
        if (Schema::hasTable('translations')) {
            if (Schema::hasColumn('translations', 'translatable_type')) {
                $items = DB::select('select * from translations');
                foreach ($items as $item) {
                    // Points to new namespace Redooor\\Redminportal\\App\\Models\\
                    $new_type_array = explode('\\', $item->translatable_type);
                    $last_model = array_pop($new_type_array);
                    $new_type = 'Redooor\\Redminportal\\App\\Models\\' . $last_model;
                    DB::table('translations')->where('id', $item->id)
                        ->update([
                        'translatable_type' => $new_type
                    ]);
                }
            }
        }
    }
312262
public function up()
    {
        // drop all columns (to add columns and also for column order)
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('name');
            $table->dropColumn('email');
            $table->dropColumn('password');
            $table->dropColumn('email_verified_at');
            $table->dropColumn('remember_token');
            $table->dropColumn('created_at');
            $table->dropColumn('updated_at');
        });

        Schema::table('users', function (Blueprint $table) {
            $table->string('firstname')->nullable();
            $table->string('lastname')->nullable();
            $table->string('email', 50)->index()->unique();
            $table->string('cellphone', 50)->nullable();
            $table->string('telephone', 50)->nullable();
            $table->string('image', 50)->nullable();
            $table->string('gender', 10)->nullable();
            $table->date('born_at')->nullable();
            $table->string('password')->nullable();
            $table->rememberToken();
            $table->string('confirmation_token')->nullable();
            $table->timestamp('logged_in_at')->nullable();
            $table->timestamps();
            $table->timestamp('confirmed_at')->nullable();
            $table->timestamp('password_updated_at')->nullable();
            $table->integer('deleted_by')->unsigned()->nullable();
            $table->timestamp('deleted_at')->nullable();
        });
    }
451233
public function up()
    {
        if ( ! Schema::hasTable('provinces')) {
            Schema::create('provinces', function(Blueprint $table) {
                $table->increments('id');
                $table->string('province', 50);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('counties')) {
            Schema::create('counties', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('province_id');
                $table->foreign('province_id')->references('id')->on('provinces')->onDelete('cascade');
                $table->string('county', 75);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('districts')) {
            Schema::create('districts', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('county_id');
                $table->foreign('county_id')->references('id')->on('counties')->onDelete('cascade');
                $table->string('district', 75);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('neighborhoods')) {
            Schema::create('neighborhoods', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('district_id');
                $table->foreign('district_id')->references('id')->on('districts')->onDelete('cascade');
                $table->string('neighborhood', 150);

                $table->engine = 'InnoDB';
            });
        }

        if ( ! Schema::hasTable('postal_codes')) {
            Schema::create('postal_codes', function(Blueprint $table) {
                $table->increments('id');
                $table->unsignedInteger('neighborhood_id');
                $table->foreign('neighborhood_id')->references('id')->on('neighborhoods')->onDelete('cascade');
                $table->char('postal_code', 6);

                $table->engine = 'InnoDB';
            });
        }
    }
1246563
public function up() {
		$db = Database::get();
		$classnames = $db->get_column('SELECT DISTINCT classname FROM object_text');
		foreach ($classnames as $classname) {
			$class_parents = class_parents($classname);
			if ($class_parents !== false && count($class_parents) > 0) {
				$class = array_pop($class_parents);
				$db->query("UPDATE object_text SET classname = ? WHERE classname = ?", [ $class, $classname ]);
			}
		}
	}