create :: HasLogFunc e => FilePath -> LogIdentity -> RIO e EventLog
create dir id = do
    logDebug $ display (pack @Text $ "Creating LMDB database: " <> dir)
    logDebug $ display (pack @Text $ "Log Identity: " <> show id)
    env       <- rawOpen dir
    (m, e, f) <- createTables env
    clearEvents env e
    writeIdent env m id
    EventLog env m e f id <$> newIORef 0
  where
    createTables env =
      rwith (writeTxn env) $ \txn -> io $
        (,,) <$> mdb_dbi_open txn (Just "META")    [MDB_CREATE]
             <*> mdb_dbi_open txn (Just "EVENTS")  [MDB_CREATE, MDB_INTEGERKEY]
             <*> mdb_dbi_open txn (Just "EFFECTS") [MDB_CREATE, MDB_INTEGERKEY]
create :: HasLogFunc e => FilePath -> LogIdentity -> RIO e EventLog
create dir id = do
    logDebug $ display (pack @Text $ "Creating LMDB database: " <> dir)
    logDebug $ display (pack @Text $ "Log Identity: " <> show id)
    env       <- rawOpen dir
    (m, e, f) <- createTables env
    clearEvents env e
    writeIdent env m id
    EventLog env m e f id <$> newIORef 0
  where
    createTables env =
      rwith (writeTxn env) $ \txn -> io $
        (,,) <$> mdb_dbi_open txn (Just "META")    [MDB_CREATE]
             <*> mdb_dbi_open txn (Just "EVENTS")  [MDB_CREATE, MDB_INTEGERKEY]
             <*> mdb_dbi_open txn (Just "EFFECTS") [MDB_CREATE, MDB_INTEGERKEY]
create dir id = do
    logDebug $ display (pack @Text $ "Creating LMDB database: " <> dir)
    logDebug $ display (pack @Text $ "Log Identity: " <> show id)
    env       <- rawOpen dir
    (m, e, f) <- createTables env
    clearEvents env e
    writeIdent env m id
    EventLog env m e f id <$> newIORef 0
  where
    createTables env =
      rwith (writeTxn env) $ \txn -> io $
        (,,) <$> mdb_dbi_open txn (Just "META")    [MDB_CREATE]
             <*> mdb_dbi_open txn (Just "EVENTS")  [MDB_CREATE, MDB_INTEGERKEY]
             <*> mdb_dbi_open txn (Just "EFFECTS") [MDB_CREATE, MDB_INTEGERKEY]