Skip to content

Commit

Permalink
feat(slonik): change slonik.migrations config type (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
opichon committed Dec 21, 2022
1 parent 49975c6 commit f8b0abf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
5 changes: 2 additions & 3 deletions packages/slonik/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The plugin also includes logic to run migrations via [`postgres-migrations`](htt
# Requirements

* @dzangolab/fastify-config
* postgres-migrations
* slonik


Expand All @@ -18,13 +17,13 @@ The plugin also includes logic to run migrations via [`postgres-migrations`](htt
In a simple repo:

```bash
npm install @dzangolab/fastify-slonik slonik postgres-migrations
npm install @dzangolab/fastify-slonik slonik
```

If using in a monorepo with pnpm:

```bash
pnpm add --filter "myrepo" @dzangolab/fastify-slonik slonik postgres-migrations
pnpm add --filter "myrepo" @dzangolab/fastify-slonik slonik
```

## Usage
Expand Down
5 changes: 2 additions & 3 deletions packages/slonik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"typecheck": "tsc --noEmit -p tsconfig.json --composite false"
},
"dependencies": {
"fastify-slonik": "2.0.0"
"fastify-slonik": "2.0.0",
"postgres-migrations": "5.3.0"
},
"devDependencies": {
"@dzangolab/fastify-config": "0.10.8",
Expand All @@ -33,7 +34,6 @@
"eslint-config-custom": "0.10.8",
"fastify": "4.10.2",
"fastify-plugin": "4.4.0",
"postgres-migrations": "5.3.0",
"prettier": "2.8.1",
"slonik": "30.3.1",
"tsconfig": "0.10.8",
Expand All @@ -44,7 +44,6 @@
"@dzangolab/fastify-config": "0.10.8",
"fastify": ">=4.9.2",
"fastify-plugin": ">=4.3.0",
"postgres-migrations": ">=5.3.0",
"slonik": ">=30.3.1"
},
"engines": {
Expand Down
8 changes: 1 addition & 7 deletions packages/slonik/src/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ const migrate = async (config: ApiConfig) => {
defaultDatabase: "postgres",
} as MigrateDBConfig;

let migrationsPath = slonikConfig.migrations.development;

if (config.env === "production") {
migrationsPath = slonikConfig.migrations.production;
}

await runMigrations(dbConfig, migrationsPath);
await runMigrations(dbConfig, slonikConfig.migrations.path);
};

export default migrate;
3 changes: 1 addition & 2 deletions packages/slonik/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ type Database = {
type SlonikConfig = {
db: ConnectionOptions;
migrations: {
development: string;
production: string;
path: string;
};
};

Expand Down

0 comments on commit f8b0abf

Please sign in to comment.