Get the migration connection name.

@return string
482998
public function getConnection()
    {
        $connection = parent::getConnection();

        if ( ! app()->bound(Component::CORE)) {
            // @codeCoverageIgnoreStart
            return $connection;
            // @codeCoverageIgnoreEnd
        }

        /** @var CoreInterface $core */
        $core = app(Component::CORE);
        $cmsConnection = $core->config('database.driver');

        // If no separate database driver is configured for the CMS,
        // we can use the normal driver and rely on the prefix alone.
        if ( ! $cmsConnection) {
            return $connection;
        }

        // If we're running tests, make sure we use the correct override
        // for the CMS database connection/driver.
        // N.B. This is ignored on purpose if the default connection is not overridden normally.
        if (app()->runningUnitTests()) {
            $cmsConnection = $core->config('database.testing.driver') ?: $cmsConnection;
        }

        return $cmsConnection;
    }
963148
public function migrate()
    {
        // find migrations
        $folders = $this->app->pathfinder->search('dbupdates', '', 'path');
        // todo - sort files in folders
        foreach ($folders as $dir) {
            $files = scandir($dir);
            sort($files);
            foreach ($files as $name) {
                if (strtolower(substr($name, -4)) != '.sql') {
                    continue;
                }
                $q = $this->db->dsql()
                    ->table('_db_update')
                    ->where('name', strtolower($name))
                    ->field('status');
                if ($q->getOne() === 'ok') {
                    continue;
                }
                $migration = file_get_contents($dir.'/'.$name);
                $q->set('name', strtolower($name));
                try {
                    $this->db->dbh->exec($migration);
                    $q->set('status', 'ok')->replace();
                } catch (Exception $e) {
                    $q->set('status', 'fail')->replace();
                    if (!$e instanceof BaseException) {
                        $e = $this->exception()
                            ->addMoreInfo('Original error', $e->getMessage());
                    }
                    throw $e->addMoreInfo('file', $name);
                }
            }
        }

        return $this;
    }
1070562
public function getConnections()
    {
        $connections = [];
        foreach ($this->getConnectionNames() as $name) {
            $connections[$name] = $this->getConnection($name);
        }

        return $connections;
    }
1098081
public function getAllMigrations()
    {
        $iterator = new \DirectoryIterator($this->configuration->getMigrationsDirectory());
        $migrations = [];

        foreach ($iterator as $file) {
            $fileName = (string) $file;

            if ($fileName === '.'|| $fileName === '..') {
                continue;
            }

            if (!is_dir($file->getPathname())) {
                // Ignore files that might be in the migrations directory, like documentation or
                // a .gitignore or .gitkeep file.
                continue;
            }

            $name = new Name($fileName);
            $isApplied = $this->isMigrationApplied($name);

            $migrations[] = new Migration($name, $isApplied);
        }

        usort($migrations, function (Migration $a, Migration $b) {
            return strcmp($a->getName(), $b->getName());
        });

        return $migrations;
    }
905195
protected function getMigrationPath(): string
    {
        if (! $this->laravel->files->exists($path = $this->laravel['path'].DIRECTORY_SEPARATOR.$this->moduleName())) {
            throw new \Exception("Invalid path: {$path}");
        }

        return $path.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'migrations';
    }
556720
protected function getConnectionDescription() {
        $host = $this->host;
        $port = $this->port     ? ':'.$this->port     : '';
        $db   = $this->database ? '/'.$this->database : '';
        return $host.$port.$db;
    }
1174876
protected function getMigrationPath()
    {
        $path = $this->input->getOption('path');

        if (!is_null($realPath = $this->input->getOption('realpath'))) {
            return $realPath;
        }

        if (!is_null($package = $this->input->getOption('package'))) {
            is_null($path) && $path = 'resources/migrations';

            return $this->packagePath . '/' . $package . '/' . $path;
        }

        if (!is_null($path)) {
            return $this->laravel['path.base'] . '/' . $path;
        }

        return $this->laravel['path.database'] . '/migrations';
    }
419099
protected function migrationsToRun()
    {
        // Get all migration files
        $path = APPDIR.'/src/'.str_replace('\\', '/', $this->migrationNamespace);

        if (! is_dir($path)) {
            return [];
        }

        $dir = new DirectoryIterator($path);

        $migrations = [];
        foreach ($dir as $file) {
            // Ignore directories and dotfiles (e.g. .DS_Store)
            if (! $file->isFile() or substr($file->getBasename(), 0, 1) === '.') {
                continue;
            }

            $class = $this->migrationNamespace.$file->getBasename('.php');

            $migrations[] = new $class;
        }

        $alreadyExecutedMigrations = $this->alreadyExecutedMigrations();

        $migrationsToRun = [];
        foreach ($migrations as $migration) {
            $compare = new ArrayObject([
                'description' => $migration->getDescription(),
                'timestamp'   => $migration->getTimestamp(),
            ]);

            if (in_array($compare, $alreadyExecutedMigrations)) {
                continue;
            }

            $migrationsToRun[] = $migration;
        }

        return $migrationsToRun;
    }
923084
protected function getNewMigrations()
    {
        $applied = [];

        foreach ($this->getMigrationHistory(null) as $version => $time) {
            $applied[substr($version, 1, 13)] = true;
        }

        $migrations = [];
        $handle = opendir($this->migrationPath);

        while (($file = readdir($handle)) !== false) {
            if ($file === '.' || $file === '..') {
                continue;
            }

            $path = $this->migrationPath . DIRECTORY_SEPARATOR . $file;

            if (preg_match('/^(m(\d{6}_\d{6})_.*?)\.php$/', $file, $matches)
                && !isset($applied[$matches[2]]) && is_file($path)) {
                $migrations[] = $matches[1];
            }
        }

        closedir($handle);
        sort($migrations);

        return $migrations;
    }
156138
public function getMigrationStatus()
    {
        $configuration = $this->getMigrationConfiguration();

        $executedMigrations = $configuration->getMigratedVersions();
        $availableMigrations = $configuration->getAvailableVersions();
        $executedUnavailableMigrations = array_diff($executedMigrations, $availableMigrations);

        $numExecutedUnavailableMigrations = count($executedUnavailableMigrations);
        $numNewMigrations = count(array_diff($availableMigrations, $executedMigrations));

        return [
            'Name' => $configuration->getName() ? $configuration->getName() : 'Doctrine Database Migrations',
            'Database Driver' => $configuration->getConnection()->getDriver()->getName(),
            'Database Name' => $configuration->getConnection()->getDatabase(),
            'Configuration Source' => 'manually configured',
            'Version Table Name' => $configuration->getMigrationsTableName(),
            'Version Column Name' => $configuration->getMigrationsColumnName(),
            'Migrations Namespace' => $configuration->getMigrationsNamespace(),
            'Migrations Target Directory' => $configuration->getMigrationsDirectory(),
            'Previous Version' => $this->getFormattedVersionAlias('prev', $configuration),
            'Current Version' => $this->getFormattedVersionAlias('current', $configuration),
            'Next Version' => $this->getFormattedVersionAlias('next', $configuration),
            'Latest Version' => $this->getFormattedVersionAlias('latest', $configuration),
            'Executed Migrations' => count($executedMigrations),
            'Executed Unavailable Migrations' => $numExecutedUnavailableMigrations,
            'Available Migrations' => count($availableMigrations),
            'New Migrations' => $numNewMigrations,
        ];
    }
248950
public function getName()
    {
        $name = 'Request consumer: ';
        if ($this->queue) {
            $name .= ' on queue: ' . $this->queue->getName();
            $name .= ', on host: ' 
                . $this->queue->getConnection()->getHost() . ':' . $this->queue->getConnection() ->getPort();
            $name .= ', ' . $this->queue->getConnection()->isConnected() ? 'connected' : 'disconnected';
        }
        
        return $name;
    }
964773
public function getConnectionTableName()
    {
        $type_names = [$this->getSourceTypeName(), $this->getTargetTypeName()];
        sort($type_names);

        return implode('_', $type_names);
    }
684969
public function getConnectionUrl(): string
    {
        if (array_key_exists('unix_socket', $this->connection_params)) {
            return sprintf(
                'mysql://%s@localhost/%s?unix_socket=%s&server_version=%s',
                $this->connection_params['user'] ?? get_current_user(),
                $this->connection_params['dbname'] ?? 'test',
                $this->connection_params['unix_socket'],
                $this->connection_params['server_version'] ?? '5.6'
            );
        }

        return sprintf(
            'mysql://%s:%s@%s:%s/%s?server_version=%s',
            $this->connection_params['user'] ?? get_current_user(),
            $this->connection_params['password'] ?? '',
            $this->connection_params['host'] ?? 'localhost',
            $this->connection_params['port'] ?? 3306,
            $this->connection_params['dbname'] ?? 'test',
            $this->connection_params['server_version'] ?? '5.6'
        );
    }
325887
public function getTableName()
    {
        if ($this->table_exists === null && !in_array($this->table_name, $this->connection->getTableNames())) {
            $this->connection->execute('CREATE TABLE ' . $this->connection->escapeTableName($this->table_name) . ' (
                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
                `migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
                `executed_at` datetime NOT NULL,
                PRIMARY KEY (`id`),
                UNIQUE KEY `migration` (`migration`),
                KEY `executed_on` (`executed_at`)
            ) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;');

            $this->table_exists = true;
        }

        return $this->table_name;
    }
509786
public function getConnection()
	{
		if ($this->connection === null)
		{
			$connection = null;

			// We will now provide the query grammar to the connection.
			switch ($this->driverName)
			{
				case 'mysql':
					$connection = '\Illuminate\Database\MySqlConnection';
					break;

				case 'pgsql':
					$connection = '\Illuminate\Database\PostgresConnection';
					break;

				case 'sqlsrv':
					$connection = '\Illuminate\Database\SqlServerConnection';
					break;

				case 'sqlite':
					$connection = '\Illuminate\Database\SQLiteConnection';
					break;

				default:
					throw new \InvalidArgumentException("Cannot determine grammar to use based on {$this->driverName}.");
					break;
			}
			
			$this->connection = new $connection($this->pdo, '', $this->tablePrefix);
		}

		return $this->connection;
	}
1134882
public static function getDefaultConnection()
    {
        if (self::$defaultConnection === null) {
            $databaseSettings = StemSettings::singleton();

            self::$defaultConnection = static::getConnection($databaseSettings);

            if ($databaseSettings->stickyWriteConnection) {
                self::$readOnlyConnection = self::$defaultConnection;
            }
        }

        return self::$defaultConnection;
    }
67125
public function getAppliedMigrations( )
    {
        $query = "SELECT * FROM $this->migrationTable";
        
        $applied = $this->db->query( $query );
        
        $list = array();
        
        foreach( $applied as $mig )
        {
            $list[] = $mig[ 'migration_name' ];
        }
        
        $list = array_reverse( $list );
        
        return $this->filter( self::ON_GET_APPLIED_MIGRATIONS_FILTER, $list );
    }