Run migration

@return $this
495487
private function runMigration()
    {
        $this->info("Running database migration...");
        $this->call('migrate', ['--force' => true]);

        $this->line('');
        $this->advanceBar();

        $this->clearCaches();
        return $this;
    }
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');
    }
1340998
public function up()
    {
        Schema::create($this->prefixCmsTable('users'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('email');
            $table->string('password');
            $table->text('permissions')->nullable();
            $table->timestamp('last_login')->nullable();
            $table->string('first_name')->nullable();
            $table->string('last_name')->nullable();
            $table->boolean('is_superadmin')->default(false);
            $table->nullableTimestamps();

            $table->unique('email');
        });

        Schema::create($this->prefixCmsTable('activations'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->string('code');
            $table->boolean('completed')->default(0);
            $table->timestamp('completed_at')->nullable();
            $table->nullableTimestamps();

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('activations_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('persistences'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->string('code');
            $table->nullableTimestamps();

            $table->unique('code');

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('persistences_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('reminders'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->string('code');
            $table->boolean('completed')->default(0);
            $table->timestamp('completed_at')->nullable();
            $table->nullableTimestamps();

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('reminders_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('roles'), function (Blueprint $table) {
            $table->increments('id');
            $table->string('slug');
            $table->string('name');
            $table->text('permissions')->nullable();
            $table->nullableTimestamps();

            $table->unique('slug');
        });

        Schema::create($this->prefixCmsTable('role_users'), function (Blueprint $table) {
            $table->integer('user_id')->unsigned();
            $table->integer('role_id')->unsigned();
            $table->nullableTimestamps();

            $table->primary(['user_id', 'role_id']);

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('role_users_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');

            $table->foreign('role_id', 'fk_' . $this->prefixCmsTable('role_users_roles1'))
                  ->references('id')->on($this->prefixCmsTable('roles'))
                  ->onDelete('cascade');
        });

        Schema::create($this->prefixCmsTable('throttle'), function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned()->nullable();
            $table->string('type');
            $table->string('ip')->nullable();
            $table->nullableTimestamps();

            $table->index('user_id');

            $table->foreign('user_id', 'fk_' . $this->prefixCmsTable('throttle_users1'))
                  ->references('id')->on($this->prefixCmsTable('users'))
                  ->onDelete('cascade');
        });
    }
128422
public function up()
    {
        Schema::create('netcore_category__categories', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('category_group_id');

            // Nested set columns.
            NestedSet::columns($table);

            // Simple icon. (select2)
            $table->string('icon')->nullable();

            $table->unsignedInteger('items_count')->default(0);
            $table->timestamps();
            $table->softDeletes();

            $table
                ->foreign('category_group_id', 'category::categories-category_group_foreign')
                ->references('id')
                ->on('netcore_category__category_groups')
                ->onDelete('CASCADE');
        });

        Schema::create('netcore_category__category_translations', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('category_id');

            $table->string('locale', 2)->index();
            $table->string('name');
            $table->string('slug')->index()->unique();
            $table->string('full_slug')->nullable()->index();
            $table->timestamps();

            $table
                ->foreign('category_id', 'category::category_translations-category_foreign')
                ->references('id')
                ->on('netcore_category__categories')
                ->onDelete('CASCADE');
        });
    }
1336139
public static function migrate()
    {
        foreach (static::$foreignKeys as $foreignKey) {
            Schema::table($foreignKey['table'], function (Blueprint $table) use ($foreignKey) {
                $table->foreign($foreignKey['column'], $foreignKey['key_name'])
                ->references($foreignKey['primary_key'])
                ->on($foreignKey['reference_table'])
                ->onDelete($foreignKey['on_delete'])
                ->onUpdate($foreignKey['on_update']);
            });
        }

        static::$foreignKeys = [];
    }
888822
public function up()
    {
    	if (Schema::hasTable('users')) {

    		Schema::table('users', function (Blueprint $table) {
	            
	            if (!Schema::hasColumn('users', 'is_admin')) {

	            	$table->tinyInteger('is_admin')->default(0)->comment('1: admin, 0: not is admin');
	            }

	            if (!Schema::hasColumn('users', 'name')) {
	            	$table->string('name');
	            }
	            
	            if (!Schema::hasColumn('users', 'email')) {
	            	$table->string('email')->unique();
	            }

	            if (!Schema::hasColumn('users', 'password')) {
	            	$table->string('password');
	            }

	            if (!Schema::hasColumn('users', 'remember_token')) {
	            	$table->rememberToken();
	            }


	        });
    	}

    	else {

    		Schema::create('users', function (Blueprint $table) {
	            $table->increments('id');
	            $table->string('name');
	            $table->string('email')->unique();
	            $table->string('password');
	            $table->tinyInteger('is_admin')->default(0)->comment('1: admin, 0: not is admin');
	            $table->rememberToken();
	            $table->timestamps();
	        });
    	}
        
    }
1262943
def run_migrations():
    
    with engine.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=Model.metadata)

        with context.begin_transaction():
            context.run_migrations()
751003
public static function migrate() {
        $connection = \DLModel::getConnectionResolver()->connection();
        if ($connection->getPdo()) {
            $builder = $connection->getSchemaBuilder();
            if (!$builder->hasTable('modules')) {
                foreach (glob(__DIR__ . '/../../migrations/app/*.php') as $file) {
                    $migration = require($file);
                    if (is_array($migration)) {
                        $builder->create($connection->getTablePrefix() . key($migration), current($migration));
                    }
                }
            }
        }
    }
2109
public function up()
    {
        $table = file_get_contents(dirname(__FILE__) . '/media.sql');
        return $this->db->createCommand($table)->execute();
    }
818697
public function up ()
    {

        // categories table
        Schema::create(config('categories.categories_table_name') , function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->increments('id');
            $table->string('title' , 200);
            $table->string('slug' , 250);
            $table->string('description' , 180)->nullable();
            $table->string('model_type' , 200);
            $table->integer('count')->default(0);
            $table->integer('parent')->default(0);
            $table->text('meta')->nullable(); // for custom fields
            $this->makeOtherFields($table);
            $table->softDeletes();
            $table->timestamps();
        });

        // relation table
        Schema::create(config('categories.relation_table_name') , function (Blueprint $table) {
            $table->engine = "InnoDB";
            $table->integer('categorieable_id');
            $table->string('categorieable_type' , 200);
            $table->integer('categories_id')->unsigned()->index();
            $table->foreign('categories_id')->references('id')->on('categories')->onDelete('cascade');
        });

        // insert default category when migrating
        \Illuminate\Support\Facades\DB::table('categories')->insert([
            'id' => 1 ,
            'title' => config('categories.default_category.title') ,
            'slug' => config('categories.default_category.slug') ,
            'model_type' => 'NONE'
        ]);

    }
1031140
public function migrateUp()
    {
        Schema::create('tddd_runs', function (Blueprint $table) {
            $table->increments('id');

            $table->integer('test_id')->unsigned();

            $table->boolean('was_ok');

            $table->mediumText('log');

            $table->text('html')->nullable();

            $table->text('png')->nullable();

            $table->timestamps();
        });

        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->foreign('test_id')
                ->references('id')
                ->on('tddd_tests')
                ->onDelete('cascade')
                ->onUpdate('cascade');
        });
    }
125842
protected function migrate()
    {
        if (! $this->container['migrator']->repositoryExists()) {
            throw new Exception('Migration table not found.');
        }

        $this->container['migrator']->run($this->getAttribute('path').'/database/migrations');
    }
500474
public function migrateUp()
    {
        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->mediumText('log_new')->nullable()->after('was_ok');
        });

        Database::statement('update tddd_runs set log_new = log;');

        Schema::table('tddd_runs', function (Blueprint $table) {
            $table->dropColumn('log');
            $table->renameColumn('log_new', 'log');
        });
    }
46722
public function migrateModule($module)
    {
        $this->migrator->run(base_path() . '/modules/'.strtolower($module).'/database/migrations');

        $this->note($module);

        foreach ($this->migrator->getNotes() as $note) {
            $this->note(' - '.$note);
        }

        return $this;
    }
1007811
public static function _init()
	{
		logger(\Fuel::L_DEBUG, 'Migrate class initialized');

		// load the migrations config
		\Config::load('migrations', true);

		// set the name of the table containing the installed migrations
		static::$table = \Config::get('migrations.table', static::$table);

		// set the name of the connection group to use
		static::$connection = \Config::get('migrations.connection', static::$connection);

		// installs or upgrades the migration table to the current schema
		static::table_version_check();

		//get all installed migrations from db
		$migrations = \DB::select()
			->from(static::$table)
			->order_by('type', 'ASC')
			->order_by('name', 'ASC')
			->order_by('migration', 'ASC')
			->execute(static::$connection)
			->as_array();

		// convert the db migrations to match the config file structure
		foreach($migrations as $migration)
		{
			isset(static::$migrations[$migration['type']]) or static::$migrations[$migration['type']] = array();
			static::$migrations[$migration['type']][$migration['name']][] = $migration['migration'];
		}
	}
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' );
		}
	}
637332
public function up()
    {
        Schema::create('people', function (Blueprint $table) {
            $table->integer('id', true, true);
            $table->string('name', 191)->nullable();
            $table->string('email', 191);
            $table->boolean('enabled')->default(1);
            $table->string('password', 60)->nullable();
            $table->boolean('superuser')->default(false);
            $table->rememberToken();
            $table->unique(['email', 'deleted_at']);
            $table->index(['deleted_at', 'name']);
            $table->softDeletes();
            $table->integer('deleted_by')->unsigned()->nullable();
            $table->timestamp('last_login')->nullable();

            $table
                ->foreign('deleted_by')
                ->references('id')
                ->on('people')
                ->onDelete('set null');
        });
    }