markMigrated.

@param bool $replay This is a replayed migration, do an update instead of an insert
174559
public function markMigrated($replay = false)
    {
        $this->configuration->createMigrationCollection();
        $collection = $this->configuration->getCollection();

        $document = ['v' => $this->version, 't' => $this->createMongoTimestamp()];

        if ($replay) {
            $query = ['v' => $this->version];
            // If the user asked for a 'replay' of a migration that
            // has not been run, it will be inserted anew
            $options = ['upsert' => true];
            $collection->update($query, $document, $options);
        } else {
            $collection->insert($document);
        }
    }
43256
public function setDone() {
        $migration = $this->getMigration();
        if ($migration['state']) {
            return true; //alredy done
        }
        $this->db()->update($this->table, array('state' => true), array('id' => $migration['id']));
    }
932165
public function write(string $identifier, MigrationList $executedMigrations): void
    {
        $exchange = $this->settings['exchange'];
        $client = $this->connector->getConnection();
        $uri = sprintf('/api/bindings/%1$s/e/%2$s/e/%2$s', $this->getVhost(), $exchange);

        // delete existing migration list entries before rewriting
        foreach ($this->loadMigrations() as $migration) {
            $client->delete($uri.'/'.$migration['properties_key']);
        }

        foreach ($executedMigrations as $migration) {
            $client->post($uri, [
                'body' => json_encode([
                    'routing_key' => $identifier,
                    'arguments' => $migration->toNative()
                ])
            ]);
        }
    }
1373691
public function runMigrationList($migrations, $pretend = false)
	{
		// First we will just make sure that there are any migrations to run. If there
		// aren't, we will just make a note of it to the developer so they're aware
		// that all of the migrations have been run against this database system.
		if (count($migrations) == 0)
		{
			$this->note('<info>Nothing to migrate.</info>');

			return;
		}

		$batch = $this->repository->getNextBatchNumber();

		// Once we have the array of migrations, we will spin through them and run the
		// migrations "up" so the changes are made to the databases. We'll then log
		// that the migration was run so we don't repeat it next time we execute.
		foreach ($migrations as $file)
		{
			$this->runUp($file, $batch, $pretend);
		}
	}
471367
public function migrateExpiredJobs($from, $to, $attempt = true)
    {
        $this->redis->watch($from);

        $jobs = $this->redis->zRangeByScore($from, '-inf', $this->currentTime());

        if (!empty($jobs)) {
            $this->transaction(function () use ($from, $to, $jobs, $attempt) {

                $this->redis->zRemRangeByRank($from, 0, count($jobs) - 1);

                for ($i = 0; $i < count($jobs); $i += 100) {

                    $values = array_slice($jobs, $i, 100);

                    $this->redis->rPush($to, ...$values);
                }
            });
        }

        $this->redis->unwatch();
    }
56292
protected function writeMigration($name, $extension, $table, $create)
    {
        $path = $this->creator->create($name, $extension, $table, $create);

        $file = pathinfo($path, PATHINFO_FILENAME);

        $this->info("Created migration: $file");
    }
852165
public function migrateExpiredJobs($from, $to)
    {
        $options = ['cas' => true, 'watch' => $from, 'retry' => 10];

        $this->__handler->transaction($options, function ($transaction) use ($from, $to) {

            $queueData = $this->getExpiredJobs(
                $transaction, $from, $time = time()
            );

            if (count($queueData) > 0)
            {
                $this->removeExpiredJobs($transaction, $from, $time);

                $this->pushExpiredJobsOntoNewQueue($transaction, $to, $queueData);
            }
        });
    }
502893
protected function runMigration($migration, $method)
    {
        $callback = function () use ($migration, $method) {
            if (method_exists($migration, $method)) {
                $migration->{$method}();
            }
        };

        $callback();
    }
1115153
private function verifyMigrated()
    {
        $process = new Process('php artisan migrate:status');
        $process->run();

        if (strpos($process->getOutput(), 'No migrations found') !== false) {
            $this->comment('Running migrate command...');
            $this->call('migrate');
        }
    }
1002784
public function apply()
    {

        $files = $this->getMigrationsFiles();
        $lastMigration = null;

        asort($files);

        foreach ($files as $key => $value) {
            if ($key <= $this->getVersion()) continue;
            include $this->migrateManager->storagePath . '/' . $value;
            $className = "Migration_$key";
            $class = new $className();
            $class->up();
            $lastMigration = $key;
            unset($class);
        }

        if (!is_null($lastMigration)) {
            $this->setVersion($lastMigration);
            echo Utils::colorize("Done!", "SUCCESS");
        } else {
            echo Utils::colorize("The latest version is already installed.", "NOTE");
        }

    }
420054
private function saveMigration(Connection $connection, string $class): void
    {
        $format = $connection->getSchemaManager()->getDatabasePlatform()->getDateTimeFormatString();
        $now    = (new DateTimeImmutable())->format($format);
        $connection->insert(static::MIGRATIONS_TABLE, [
            static::MIGRATIONS_COLUMN_CLASS       => $class,
            static::MIGRATIONS_COLUMN_MIGRATED_AT => $now,
        ]);
    }
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' );
		}
	}
374507
protected function registerMigrateMakeCommand(): void
    {
        $this->app->singleton('command.migrate.make', function ($app) {
            // Once we have the migration creator registered, we will create the command
            // and inject the creator. The creator is responsible for the actual file
            // creation of the migrations, and may be extended by these developers.
            $creator = $app['migration.creator'];

            $composer = $app['composer'];

            return new MigrateMakeCommand($creator, $composer);
        });
    }
1180724
private function makeMigration($option)
    {
        if ($option) {
            $table = Str::plural(Str::snake(class_basename($this->argument('name'))));

            $this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
        }
    }
470006
public function save($trace = false)
    {
        $retval = parent::save($trace);

        $this->nb_attachment_list->iterate(
            function ($key, CNabuIContactProspectAttachment $nb_attachment) use ($retval) {
                $retval |= $nb_attachment->save();
                return true;
            }
        );

        return $retval;
    }
255749
public function markModified()
    {
        // marks this collection as newly modified
        $db = Loader::db();
        $dh = Loader::helper('date');
        $cDateModified = $dh->getOverridableNow();

        $v = [$cDateModified, $this->cID];
        $q = 'update Collections set cDateModified = ? where cID = ?';
        $r = $db->prepare($q);
        $res = $db->execute($r, $v);
    }
1367146
public function down(Migration $migration, $loadFromFile = false)
    {
        if ($loadFromFile) {
            $this->fileRepository->loadSql($migration);
        } else {
            $this->dbRepository->loadSql($migration);
        }

        $func = function () use ($migration) {
            $this->_processMigrationSql($migration->getDown());
            $this->dbRepository->delete($migration);
        };

        $this->_processMigration($migration, $func);
    }