ensureOpen method

  1. @override
Future<bool> ensureOpen(
  1. QueryExecutorUser user
)
override

Opens the executor, if it has not yet been opened.

Implementation

@override
Future<bool> ensureOpen(QueryExecutorUser user) {
  return _openingLock.synchronized(() async {
    if (_closed) {
      return Future.error(StateError(
          "Can't re-open a database after closing it. Please create a new "
          'database connection and open that instead.'));
    }

    final alreadyOpen = await delegate.isOpen;
    if (alreadyOpen) {
      _ensureOpenCalled = true;
      return true;
    }

    await delegate.open(user);
    _ensureOpenCalled = true;
    await _runMigrations(user);
    return true;
  });
}