mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-17 04:46:05 +00:00
move postgres to a separate package
This commit is contained in:
25
packages/postgres/test/setup.ts
Normal file
25
packages/postgres/test/setup.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { Kysely } from "kysely";
|
||||
import { PostgresConnection, PostgresIntrospector, type PostgresConnectionConfig } from "../src";
|
||||
|
||||
export const info = {
|
||||
host: "localhost",
|
||||
port: 5430,
|
||||
user: "postgres",
|
||||
password: "postgres",
|
||||
database: "bknd",
|
||||
};
|
||||
|
||||
export function createConnection(config: PostgresConnectionConfig = {}) {
|
||||
return new PostgresConnection({
|
||||
...info,
|
||||
...config,
|
||||
});
|
||||
}
|
||||
|
||||
export async function cleanDatabase(connection: PostgresConnection) {
|
||||
const kysely = connection.kysely;
|
||||
|
||||
// drop all tables & create new schema
|
||||
await kysely.schema.dropSchema("public").ifExists().cascade().execute();
|
||||
await kysely.schema.createSchema("public").execute();
|
||||
}
|
||||
Reference in New Issue
Block a user