Migrates the database to the latest version, enabling migrations if necessary.
331697
public void migrate(Log log, String encoding) {

        createSchemaVersionTable();

        final Collection<Migration> pendingMigrations = getPendingMigrations();

        if (pendingMigrations.isEmpty()) {
            log.info("No new migrations are found");
            return;
        }
        log.info("Migrating database, applying " + pendingMigrations.size() + " migration(s)");
        Migration currentMigration = null;

        try {
            connection().setAutoCommit(false);
            for (Migration migration : pendingMigrations) {
                currentMigration = migration;
                log.info("Running migration " + currentMigration.getName());
                long start = System.currentTimeMillis();

                currentMigration.migrate(encoding);
                versionStrategy.recordMigration(currentMigration.getVersion(), new Date(start), (start - System.currentTimeMillis()));
                connection().commit();
            }
        } catch (Exception e) {
            try{connection().rollback();}catch(Exception ex){throw new MigrationException(e);}
            assert currentMigration != null;
            throw new MigrationException("Migration for version " + currentMigration.getVersion() + " failed, rolling back and terminating migration.", e);
        }
        log.info("Migrated database");
    }
1306870
public function up()
    {
        // CouchDB Service Configuration
        Schema::create(
            'couchdb_config',
            function (Blueprint $t){
                $t->integer('service_id')->unsigned()->primary();
                $t->foreign('service_id')->references('id')->on('service')->onDelete('cascade');
                $t->string('dsn')->default(0)->nullable();
                $t->text('options')->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.
    }
1326380
public function up()
    {
        Schema::create('jobs', function (Blueprint $table) {
            $table->engine = 'InnoDB';

            $table->bigIncrements('id');
            $table->string('queue');
            $table->text('payload');
            $table->tinyInteger('attempts')->unsigned();
            $table->tinyInteger('reserved')->unsigned();
            $table->unsignedInteger('reserved_at')->nullable();
            $table->unsignedInteger('available_at');
            $table->unsignedInteger('created_at');
        });
    }
597584
public function up(): void
    {
        Schema::create(config('queue.connections.database.table'), function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('queue');
            $table->longText('payload');
            $table->tinyInteger('attempts')->unsigned();
            $table->integer('reserved_at')->unsigned()->nullable();
            $table->integer('available_at')->unsigned();
            $table->integer('created_at')->unsigned();

            // Indexes
            $table->index('queue');
        });
    }
1196614
public function up()
    {
        $table = $this->table('settings');
        $table->addColumn('scope', 'string', ['limit' => 255, 'null' => true])
            ->addColumn('field', 'string', ['limit' => 255, 'null' => true])
            ->addColumn('value', 'text', ['null' => true])
            ->addColumn('serialized', 'boolean', ['null' => false, 'default' => 0])
            ->addColumn('created', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP'])
            ->addColumn('modified', 'datetime', ['null' => false, 'default' => 'CURRENT_TIMESTAMP']);
        $table->create();

        $this->unsignedIntId($table);
        $table->save();
    }
186444
public function up()
    {
        $record = new MigrationRecord();
        if ($this->connection !== null) {
            $record->setConnection($this->connection);
        }
        $record->migration = $this->name;
        $record->save();
    }
1353512
public function up()
    {
        Schema::create('scaffoldinterfaces', function (Blueprint $table) {
            $table->increments('id');
            $table->String('package');
            $table->String('migration');
            $table->String('model');
            $table->String('controller');
            $table->String('views');
            $table->String('tablename');
            $table->timestamps();
        });
    }
852088
public function up()
    {
        $timeThen = microtime(true);

        //remove anahita from nodes and edges table names
        dbexec('RENAME TABLE #__anahita_nodes TO #__nodes');
        dbexec('RENAME TABLE #__anahita_edges TO #__edges');

        if(!dbexists('SHOW COLUMNS FROM `#__nodes` LIKE "verified"')) {
          dbexec("ALTER TABLE `#__nodes` ADD `verified` TINYINT(1) NOT NULL DEFAULT 0 AFTER `enabled`");
        }

        dbexec('ALTER TABLE #__nodes
                ADD `cover_filename` VARCHAR(255) NULL AFTER `filesize`,
                ADD `cover_filesize` INT(11) NULL AFTER `cover_filename`,
                ADD `cover_mimetype` VARCHAR(100) NULL AFTER `cover_filesize`');

        dbexec('ALTER TABLE #__nodes ADD `pinned` TINYINT(1) NOT NULL DEFAULT \'0\' AFTER `enabled`');

        //some legacy cleanup
        $legacyTables = array(
            'categories',
            'content',
            'content_frontpage',
            'core_log_items',
            'migration_backlinks',
            'migrations',
            'sections',
            'stats_agents',
            'tagmeta',
            'core_log_searches',
            'anahita_oauths');

        foreach ($legacyTables as $legacyTable) {
            dbexec('DROP TABLE IF EXISTS #__'.$legacyTable);
        }

        //delete a legacy record
        dbexec('DELETE FROM `#__components` WHERE `option` = \'com_mailto\' ');

        //add the hashtag contentfilter
        dbexec('INSERT INTO `#__plugins` (name,element,folder,iscore) VALUES (\'Hashtag\', \'hashtag\',\'contentfilter\',1)');

        //create the fields required for creating hashtag nodes
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `tag_count`');
        dbexec('ALTER TABLE `#__nodes` DROP COLUMN `tag_ids`');

        //install the hashtag related extensions
        dbexec('INSERT INTO #__components (`name`,`link`,`option`,`iscore`,`enabled`) VALUES (\'Hashtags\',\'option=com_hashtags\',\'com_hashtags\',1,1)');

        $ids = array();

/*
        //fetch only the nodes that contain something that resembels a hashtag
        $query_regexp = 'body REGEXP \'#([^0-9_\s\W].{2,})\'';

        dboutput("\nActors' Hashtags\n");
        //extracting hashtag terms from actors
        $ids = dbfetch('SELECT id FROM `#__nodes` WHERE type LIKE \'ComActorsDomainEntityActor%\' AND '.$query_regexp);

        foreach ($ids as $id) {
            $entity = AnService::get('repos:actors.actor')->getQuery()->disableChain()->fetch($id);
            $hashtagTerms = $this->extractHashtagTerms($entity->description);

            foreach ($hashtagTerms as $term) {
                dboutput($term.', ');
                $entity->addHashtag($term)->save();
            }
        }

        dboutput("\nComments' hashtags\n");

        //extracting hashtag terms from comments
        $ids = dbfetch('SELECT id FROM `#__nodes` WHERE type LIKE \'ComBaseDomainEntityComment%\' AND '.$query_regexp);

        foreach ($ids as $id) {
            $entity = AnService::get('com:base.domain.entity.comment')->getRepository()->getQuery()->disableChain()->fetch($id);
            $hashtagTerms = $this->extractHashtagTerms($entity->body);

            foreach ($hashtagTerms as $term) {
                dboutput($term.', ');
                $entity->addHashtag($term)->save();
            }
        }

        dboutput("\nMedia's Hashtags\n");
        //extracting hashtag terms from mediums: notes, topics, articles, and todos
        $query = 'SELECT id FROM `#__nodes` WHERE '.$query_regexp.' AND ( '.
                    'type LIKE \'%com:notes.domain.entity.note\' '.
                    'OR type LIKE \'%com:topics.domain.entity.topic\' '.
                    'OR type LIKE \'%com:photos.domain.entity.photo\' '.
                    'OR type LIKE \'%com:photos.domain.entity.set\' '.
                    'OR type LIKE \'%com:articles.domain.entity.article\' '.
                    'OR type LIKE \'%com:todos.domain.entity.todo\' '.
                    ' ) ';

        $ids = dbfetch($query);

        foreach ($ids as $id) {
            $entity = AnService::get("repos:medium.medium")->getQuery()->disableChain()->find(array('id'=> $id));

            $hashtagTerms = $this->extractHashtagTerms($entity->description);

            foreach ($hashtagTerms as $term) {
                dboutput($term.', ');
                $entity->addHashtag($term)->save();
            }
        }
*/
        dbexec('UPDATE `#__plugins` SET published = 1 WHERE element = \'hashtag\'');

        $timeDiff = microtime(true) - $timeThen;

        dboutput("TIME: ($timeDiff)"."\n");
    }
1332825
public function up()
    {
        $connection = config('admin.database.connection') ?: config('database.default');

        $table = config('admin.extensions.config.table', 'admin_config');

        Schema::connection($connection)->create($table, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->unique();
            $table->string('value');
            $table->text('description')->nullable();
            $table->timestamps();
        });
    }
1130931
public function up()
    {
        Schema::create('connection_loader', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('driver');
            $table->string('host');
            $table->string('port');
            $table->string('database');
            $table->string('username');
            $table->string('password');
            $table->string('charset');
            $table->string('collation');
            $table->string('prefix');
            $table->boolean('strict')->default(false);
            $table->string('schema');
            $table->string('engine')->nullable();
            $table->boolean('status')->default(false);
            $table->timestamps();
        });
    }
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
                    ]);
                }
            }
        }
    }
1365131
public function up()
    {
        $table = $this->table('users');
        $table->addColumn('activated_at', 'datetime', ['null' => true, 'default' => null, 'after' => 'active']);
        $table->update();

        $this->clearModelCache();
    }
560543
def database_current_migration(self):
        
        # If the table doesn't even exist, return None.
        if not self.migration_table.exists(self.session.bind):
            return None

        # Also return None if self.migration_data is None.
        if self.migration_data is None:
            return None

        return self.migration_data.version
444790
public function up()
    {
        Schema::table('users', function (Blueprint $table) {
            if (Schema::hasColumn('users', 'deleted_at') == false) {
                $table->softDeletes();
            }
        });
    }
623955
public function up()
	{
		if(Schema::hasColumn('001_017_text', 'lang_017'))
		{
			$key = DB::select(DB::raw('SHOW KEYS FROM 001_017_text WHERE Key_name=\'fk01_001_017_text\''));

			if($key != null)
			{
				Schema::table('001_017_text', function (Blueprint $table) {
					$table->dropForeign('fk01_001_017_text');
					$table->dropIndex('fk01_001_017_text');
				});

				Schema::table('001_017_text', function (Blueprint $table) {
					// rename column, function renameColumn doesn't work
					DB::select(DB::raw('ALTER TABLE 001_017_text CHANGE lang_017 lang_id_017 VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL'));
					$table->foreign('lang_id_017', 'fk01_001_017_text')->references('id_001')->on('001_001_lang')
						->onDelete('restrict')->onUpdate('cascade');
				});
			}
		}
	}
478080
private function importMigrations()
	{
		$databaseFolder = base_path( 'resources/database/migrations/' );
		if( ! file_exists( $databaseFolder ) ) {
			return $this->line( 'no migrations to move' );
		}
		$this->moveFilesToDatabaseMigrations( $databaseFolder );
	}