diff --git a/packages/kanel-kysely/README.md b/packages/kanel-kysely/README.md index 2ecc4234..20b9baad 100644 --- a/packages/kanel-kysely/README.md +++ b/packages/kanel-kysely/README.md @@ -81,3 +81,17 @@ module.exports = { preRenderHooks: [makeKyselyHook(), kyselyCamelCaseHook], }; ``` + +## Type Filter + +If you're using Kysely for migrations, you might want to filter the types of the migration tables, such as `kysely_migration` and `kysely_migration_lock`. The `kyselyTypeFilter` will do this for you. + +```ts + const { kyselyTypeFilter } = require("kanel-kysely"); + + module.exports = { + /// ... your config here. + + typeFilter: kyselyTypeFilter, + }; +``` diff --git a/packages/kanel-kysely/src/index.ts b/packages/kanel-kysely/src/index.ts index 02f43112..394e3a1f 100644 --- a/packages/kanel-kysely/src/index.ts +++ b/packages/kanel-kysely/src/index.ts @@ -1,2 +1,3 @@ export { kyselyCamelCaseHook } from "./kyselyCamelCaseHook"; +export { kyselyTypeFilter } from "./kyselyTypeFilter"; export { default as makeKyselyHook } from "./makeKyselyHook"; diff --git a/packages/kanel-kysely/src/kyselyTypeFilter.ts b/packages/kanel-kysely/src/kyselyTypeFilter.ts new file mode 100644 index 00000000..add5d866 --- /dev/null +++ b/packages/kanel-kysely/src/kyselyTypeFilter.ts @@ -0,0 +1,4 @@ +import type { PgType } from "extract-pg-schema"; + +export const kyselyTypeFilter = (table: PgType): boolean => + !["kysely_migration", "kysely_migration_lock"].includes(table.name);