Tear down databases manually feature request
- Dominant language
- Shell
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
I think a feature that can be added to this library would be to tear down databases manually.
A use case for this would be to do this in the "tear-down" section in testing frameworks. For example, in [vitest](https://vitest.dev/) a possible implementation of this would be:
```ts
import {describe, test, beforeAll} from "vitest";
import createDb from "pg-tmp";
describe("Database test", () => {
beforeAll(async () => {
const { teardownDb } = await createDb();
// return cleanup function
return async () => {
await teardownDb();
};
});
test("specific database tests", () => {
// tests with the database.
});
});
```
This should be easy to implement using the "stop" command already implemented in `pg_tmp.sh`.
I'd be up to make a PR myself, but I figured I'd get permission first & so forth.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the existing stop command in pg_tmp.sh and the Node.js API that invokes it. Define how the manual teardown function should be exposed from createDb, using the Vitest example as the intended usage. Done means callers can invoke teardownDb during test cleanup and the existing database shutdown behavior is reused.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, postgresql, shell
- Domain
- api, databases, testing-qa
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100