Check if the required lock columns have been added to the database.
This prevents people upgrading from seeing 500 errors in their logs.

@param \Concrete\Core\Database\Connection\Connection $db
@return bool
5676
private function lockColumnsExist(Connection $db)
    {
        $schema = $db->getSchemaManager()->listTableColumns($this->table);
        return isset($schema['lockid']);
    }
1026087
public function use_database($db_name)
    {
        if (!$this->mysqli) {
            $this->last_error_id = "db_server_conn_error";
            return false;
        }
        
        $this->db_name = $db_name;
        
        if (!@$this->mysqli->select_db($this->db_name)) {
            $this->last_error = $this->mysqli->error;
            $this->last_error_id = "db_not_exists_error";
            trigger_error($this->last_error, E_USER_ERROR);
            return false;
        }
        
        return true;
    }
239521
private function _connected (array $db)
    {
        try {
            $connection = mysqli_connect ($db['host'], $db['username'], $db['password'], $db['name']);

            return $connection ? true : false;
        } catch (\Exception $e) {
            return false;
        }
    }
1203958
protected function ensureCommandsAreValid(Connection $connection)
    {
        if ($connection instanceof SQLiteConnection) {
            if ($this->commandsNamed(['dropColumn', 'renameColumn'])->count() > 1) {
                throw new BadMethodCallException(
                    "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
                );
            }

            if ($this->commandsNamed(['dropForeign'])->count() > 0) {
                throw new BadMethodCallException(
                    "SQLite doesn't support dropping foreign keys (you would need to re-create the table)."
                );
            }
        }
    }
318314
public function alreadyUpdated()
    {
        $migrations = $this->getMigrations();
        $dbMigrations = $this->getExecutedMigrations();

        // If the count of migrations and dbMigrations is equal,
        // then the update as already been updated.
        if (count($migrations) == count($dbMigrations)) {
            return true;
        }

        // Continue, the app needs an update
        return false;
    }
190378
public static function field_exists($table, $columns, $db = null)
	{
		if ( ! is_array($columns))
		{
			$columns = array($columns);
		}

		try
		{
			\DB::select_array($columns)->from($table)->limit(1)->execute($db ? $db : static::$connection);
			return true;
		}
		catch (\Database_Exception $e)
		{
			// check if we have a DB connection at all
			$connection = \Database_Connection::instance($db ? $db : static::$connection)->has_connection();

			// if no connection could be made, re throw the exception
			if ( ! $connection)
			{
				throw $e;
			}

			return false;
		}
	}
270629
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $this->fkSupported = version_compare('3.6.19', $pdo->getAttribute(PDO::ATTR_SERVER_VERSION)) < 0;
        $pdo->exec($this->buildEnableForeignKeysQuery());
    }
631104
public function commitTransaction($which_connection='')
    {
        if ($which_connection == '') {
            $which_connection = $this->default_db;
        }

        return $this->connections[$which_connection]->CommitTrans();
    }
686213
public function useDatabase(string $dbName): bool
    {
        $sql = sprintf('USE %s;', $this->quoter->quoteName($dbName));
        $result = $this->db->exec($sql);

        return (bool)$result;
    }
1030834
protected function validateDbPortInstall()
    {
        $field = 'database.port';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);
        $label = $this->translation->text('Database port');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!is_numeric($value)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        return true;
    }
1362356
public function isExists(string $database, string $table)
    {
        return $this->select(
            '
            SELECT *
            FROM system.tables 
            WHERE name=\'' . $table . '\' AND database=\'' . $database . '\''
        )->rowsAsTree('name');
    }
791898
protected function validateSqliteFile($DB_DATABASE)
    {
        if (!file_exists($DB_DATABASE)) {

            $directory = dirname($DB_DATABASE);
            if (!is_dir($directory)) {
                mkdir($directory, 0644, true);
            }

            new \PDO('sqlite:' . $DB_DATABASE);
        }
        return;

    }
73198
public function equals(Database $database) {
        $prefix = '';
        $thisTables = $this->getTables();
        $databaseTables = $database->getTables();
        $errors = [];

        foreach($thisTables as $database) {
            if(array_key_exists($database->getName(), $databaseTables)) {
                $errors = array_merge($errors, $database->equals($databaseTables[$database->getName()], $prefix));
            }
        }

        $thisTableNames = array_keys($thisTables);
        $databaseTableNames = array_keys($databaseTables);
        $diff = array_diff($databaseTableNames, $thisTableNames);
        if(!empty($diff)) {
            $errors[] = $prefix . 'Extra Tables: ' . "\n" . implode("\n", $diff);
        }
        $diff = array_diff($thisTableNames, $databaseTableNames);
        if(!empty($diff)) {
            $errors[] = $prefix . 'Missing Tables: ' . "\n" . implode("\n", $diff);
        }
        return $errors;
    }
145317
private function IsFieldLocked($field)
    {
        if (!is_array($this->locked_fields)) {
            return false;
        }
        $locked_tables = array_keys($this->locked_fields);
        $locked_fields = array_values($this->locked_fields);
        $_locked_fields = array();

        foreach ($locked_fields as $locked_field) {
            if (is_array($locked_field)) {
                foreach ($locked_field as $_locked_field) {
                    $_locked_fields[] = $_locked_field;
                }
            } else {
                $_locked_fields[] = $locked_field;
            }
        }

        if (in_array($this->table, $locked_tables) and in_array($field, $_locked_fields)) {
            return true;
        }

        return false;
    }
291270
protected function verifyConnection()
    {
        if (count(config('database.connections', [])) > 1) {
            $connections = array_keys(config('database.connections'));
            $default = array_search(config('database.default'), $connections);

            return $this->choice('Which connection do we use?', $connections, $default);
        }

        return config('database.default');
    }
732873
public function exists(string $connection = null): bool
    {
        $connection = $connection ?? $this->tenantName();

        return Arr::has($this->db->getConnections(), $connection);
    }
539382
protected function lock() {

        $this->db->lockTable($this->getTable());
        $this->locked = true;

        return true;
    }