You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(types): define `Driver` class
* feat(util): add `isDriver` validator
* feat: add `driver` option;
note: --driver purposefully overrides `exports.driver` from config file
* chore: add `custom drivers` readme docs
* break: squash `opts.client` into `opts.driver`~!
They were basically the same thing. Now just check if the `driver` string matches a supplied driver name. Customize/override by passing a Driver class or a `path/to/file.js` that contains Driver class.
* chore: update readme docs
* fix(types): remove `opts.client` key
* chore: update `--driver` help text
_Supports [`postgres`](https://www.npmjs.com/package/postgres), [`pg`](https://www.npmjs.com/package/pg), [`better-sqlite3`](https://www.npmjs.com/package/better-sqlite3), [`sqlite`](https://www.npmjs.com/package/sqlite), [`mysql`](https://www.npmjs.com/package/mysql), and [`mysql2`](https://www.npmjs.com/package/mysql2)_
36
+
_Supports [`postgres`](https://www.npmjs.com/package/postgres), [`pg`](https://www.npmjs.com/package/pg), [`better-sqlite3`](https://www.npmjs.com/package/better-sqlite3), [`sqlite`](https://www.npmjs.com/package/sqlite), [`mysql`](https://www.npmjs.com/package/mysql), [`mysql2`](https://www.npmjs.com/package/mysql2), and [custom drivers!](#drivers)_
37
37
38
38
***Lightweight**<br>
39
39
_Does **not** include any driver dependencies._
@@ -148,6 +148,35 @@ const ley = require('ley');
148
148
const successes = await ley.up({ ... });
149
149
```
150
150
151
+
## Config
152
+
153
+
> **TL;DR:** The contents of a `ley.config.js` file (default file name) is irrelevant to `ley` itself!
154
+
155
+
A config file is entirely optional since `ley` assumes that you're providing the correct environment variable(s) for your client driver. However, that may not always be possible. In those instances, a `ley.config.js`file (default file name) can be used to adjust your [driver](#drivers)'s `connect` method.
156
+
157
+
## Drivers
158
+
159
+
Out of the box, `ley` includes drivers for the following npm packages:
When no driver is specified, `ley` will attempt to autodetect usage of these libraries in the above order.
168
+
169
+
However, should you need a driver that's not listed – or should you need to override a supplied driver – you may easily do so via a number of avenues:
170
+
171
+
1) CLI users can add `--driver <filename>` to any command; or
172
+
2) Programmatic users can pass [`opts.driver`](#optsdriver) to any command; or
173
+
3) A`ley.config.js` file can exportaspecial`driver`configkey.
174
+
175
+
With any of these, if`driver` is a string then it will be passed through `require()`automatically. Otherwise, with the latter two, the `driver` is assumed to be a [`Driver`](/ley.d.ts#L45-L67) classand is validated as such.
176
+
177
+
>**Important:** All drivers must adhere to the [`Driver`interface](/ley.d.ts#L45-L67)!
178
+
179
+
151
180
## API
152
181
153
182
>**Important:** See [Options](#options) for common options shared all commands. <br>In this`API` section, you will only find **command-specific** options listed.
@@ -231,12 +260,13 @@ Default: `migrations`
231
260
232
261
The directory (relative to `opts.cwd`) to find migration files.
233
262
234
-
#### opts.client
235
-
Type: `string`<br>
263
+
#### opts.driver
264
+
Type:`string` or `Driver`
236
265
Default:`undefined`
237
266
238
-
The **name** of your desired client driver; for example, `pg`.<br>
239
-
When unspecified, `ley` searches for all supported client drivers in this order:
267
+
When defined and a `string`, this is the **name**of your [driver](#drivers) implementation. It will pass through `require()` as written. Otherwise it's expected to match a [`Driver` interface](/ley.d.ts#L45-L67) and will be validated immediately.
268
+
269
+
When undefined, `ley` searches for all supported client drivers in this order:
0 commit comments