Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(slonik): change slonik.migrations config type #115

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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