Skip to content

Commit

Permalink
improved doc
Browse files Browse the repository at this point in the history
  • Loading branch information
flodlc committed Mar 16, 2023
1 parent 2c23d3c commit 33ba36c
Showing 1 changed file with 54 additions and 8 deletions.
62 changes: 54 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,68 @@
- Fully written in TypeScript
<hr>

## Installation
## Getting Started

```sh
npm install pg-mate
# or
yarn add pg-mate
```

Then
Next, create a `pg-mate.(js|ts)` file at the root of your project as follows::

```sh
npx pg-mate init
```typescript
import { pgMate, PgMateConfig } from "../dist/index";
import { migrations } from "./migrations/index";

export const config: PgMateConfig = {
connexionUrl: "postgresql://postgres:password@localhost:5432/postgres",
migrationImports: migrations,
migrationDir: "migrations",
esm: false,
ts: true,
};

pgMate.initCli(config);
```

> Note that `pgMate.initCli(config);` enables the use of this file as a CLI
## Config

Here is the Config definition with default values:

```typescript
type PgMateConfig = {
/**
* Exemple: "postgresql://postgres:password@localhost:5432/postgres"
*/
connexionUrl: string;
/**
* Allows injecting a custom db client in migration functions.
* Default: native pg driver
* Exemple: () => knexClient
*/
getClient?: () => Promise<any>;
/**
* Default: "migrations"
*/
migrationDir?: string;
/**
* Must be the migrations import (required)
*/
migrationImports: MigrationFiles;
/**
* If type: "module" in package.json => true
* Default: false
*/
esm?: boolean;
/**
* Used to use the correction extension in migrations directory.
* Default: false
*/
ts?: boolean;
};
```

## Usage
Expand Down Expand Up @@ -92,8 +142,4 @@ node pg-mate.js --refreshIndex
ts-node pg-mate.ts --refreshIndex
```

### Basic

...

That's it! You can now use pg-mate to manage your Postgresql database migrations.

0 comments on commit 33ba36c

Please sign in to comment.