# Migration from `poolboy`

If you are using `:poolboy` and want to use `Poolex` instead, then you need to follow three simple steps.

## Installation steps

### I. Install the Poolex dependency

#### mix.exs

```diff
defp deps do
  [
-    {:poolboy, "~> 1.5.0"}
+    {:poolex, "~> 1.0"}
  ]
end
```

Install it.

```bash
mix deps.get
```

Well, you can also clean up installed dependencies locally and remove them from the `lock` file.

```bash
mix deps.clean --unlock --unused
```

### II. Update child specs

#### Your Application or Supervisor file

```diff
def init(_args) do
  children = [
-    :poolboy.child_spec(:some_pool,
-      name: {:local, :some_pool},
-      worker_module: MyApp.SomeWorker,
-      size: 100,
-      max_overflow: 50
-    )
+    {Poolex,
+      pool_id: :some_pool,
+      worker_module: MyApp.SomeWorker,
+      workers_count: 100,
+      max_overflow: 50}
  ]

  Supervisor.init(children, strategy: :one_for_one)
end
```

### III. Update call site

Use `run/3`.
Be careful, unlike `:poolboy.transaction`, `Poolex.run` returns `{:ok, result}`.

```diff
-  result = :poolboy.transaction(
-    :some_pool,
-    fn pid -> some_function(pid) end,
-    :timer.seconds(10)
-  )
+  {:ok, result} = Poolex.run(
+    :some_pool,
+    fn pid -> some_function(pid) end,
+    checkout_timeout: :timer.seconds(10)
+  )
```
