Comparing version 1.1.0 to 1.2.0
@@ -7,1 +7,2 @@ export { default as init } from './init.command.js'; | ||
export { default as help } from './help.command.js'; | ||
export { default as compose } from './compose.command.js'; |
#!/usr/bin/env node | ||
import { parser } from './modules/index.js'; | ||
const args = process.argv.slice(2); | ||
const [command, second] = args; | ||
await parser({ command, second }); | ||
const [command, second, third] = args; | ||
await parser({ command, second, third }); | ||
process.exit(0); |
@@ -1,3 +0,3 @@ | ||
import { help, init, list, make, rollback, run } from '../commands/index.js'; | ||
export default async ({ command, second }) => { | ||
import { help, init, list, make, rollback, run, compose, } from '../commands/index.js'; | ||
export default async ({ command, second, third }) => { | ||
switch (command) { | ||
@@ -20,2 +20,6 @@ case '-i': | ||
break; | ||
case '-c': | ||
case 'compose': | ||
await compose(second, third); | ||
break; | ||
case '-l': | ||
@@ -22,0 +26,0 @@ case 'list': |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"exports": "./dist/bin/index.js", | ||
@@ -9,0 +9,0 @@ "description": "Simple PostgreSQL migration tool for raw-SQL loving developers.", |
@@ -23,3 +23,3 @@ # Postgrate 🐘 | ||
After insallation, make sure that you have a `.env` file that looks like this: | ||
After installation, make sure that you have a `.env` file that looks like this: | ||
@@ -30,2 +30,5 @@ ```Bash | ||
The key defaults to `PG_DATABASE_URL`, but the `dbEnvKey` option can be used to | ||
set it to anything else. | ||
After installation, run the following command to initialize Postgrate in your | ||
@@ -87,3 +90,4 @@ project directory and create necessary configuration files: | ||
"autoCreateRollbacks": true, | ||
"migrationsTableName": "migrations" | ||
"migrationsTableName": "migrations", | ||
"dbEnvKey": "PG_DATABASE_URL" | ||
} | ||
@@ -207,2 +211,19 @@ ``` | ||
### `dbEnvKey` | ||
Allows you to set the key used in your `.env` file. Defaults to | ||
`PG_DATABASE_URL`. | ||
**E.g.** | ||
```json | ||
"dbEnvKey": "DEV_PG_DATABASE_URL" | ||
``` | ||
Output: | ||
```ts | ||
connectionString: process.env.DEV_PG_DATABASE_URL; | ||
``` | ||
## Commands | ||
@@ -209,0 +230,0 @@ |
@@ -13,2 +13,3 @@ export default function (): void { | ||
-rb, rollback Rollback a migration | ||
-c, compose Compose a migration file from folder | ||
@@ -22,3 +23,4 @@ Examples: | ||
$ postgrate -rb 1 | ||
$ postgrate -c db/queries/foo 1716554670659-foo.sql | ||
`); | ||
} |
@@ -7,1 +7,2 @@ export { default as init } from './init.command.js'; | ||
export { default as help } from './help.command.js'; | ||
export { default as compose } from './compose.command.js'; |
@@ -10,2 +10,3 @@ import fs from 'fs'; | ||
migrationsTableName: 'migrations', | ||
dbEnvKey: 'PG_DATABASE_URL', | ||
}; | ||
@@ -29,2 +30,3 @@ | ||
migrationsTableName: string; | ||
dbEnvKey: string; | ||
} |
@@ -5,6 +5,6 @@ #!/usr/bin/env node | ||
const args = process.argv.slice(2); | ||
const [command, second] = args; | ||
const [command, second, third] = args; | ||
await parser({ command, second }); | ||
await parser({ command, second, third }); | ||
process.exit(0); |
@@ -1,4 +0,12 @@ | ||
import { help, init, list, make, rollback, run } from '../commands/index.js'; | ||
import { | ||
help, | ||
init, | ||
list, | ||
make, | ||
rollback, | ||
run, | ||
compose, | ||
} from '../commands/index.js'; | ||
export default async ({ command, second }: IParserInput) => { | ||
export default async ({ command, second, third }: IParserInput) => { | ||
switch (command) { | ||
@@ -25,2 +33,7 @@ case '-i': | ||
case '-c': | ||
case 'compose': | ||
await compose(second!, third); | ||
break; | ||
case '-l': | ||
@@ -47,2 +60,3 @@ case 'list': | ||
second?: string; | ||
third?: string; | ||
} |
@@ -5,4 +5,8 @@ import dotenv from 'dotenv'; | ||
import pkg from 'pg'; | ||
import config from '../config.js'; | ||
const { dbEnvKey } = config(); | ||
const { Pool } = pkg; | ||
export default new Pool({ connectionString: process.env.PG_DATABASE_URL }); | ||
export default new Pool({ connectionString: process.env[dbEnvKey] }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44738
37
1198
255
0
12
2