Is is possible to use pgSchema with pgTableCreator

I want to use pgSchema and pgTableCreator together to have the tables in a specified schema in postgres and also have prefix for each table. Is there a way to do it?
1 Reply
Zefty
Zefty3w ago
Same question. Has anyone managed to do this? Ended up just doing this which is similar to how pgTableCreator is acutally implemented
const pgTableCreatorWithSchema = (
customizeTableName: (name: string) => string,
) => {
const pgTable: PgTableFn<string> = (name, columns, extraConfig) => {
// @ts-expect-error: columns can be object or callback, overload mismatch
return envSchema.table(customizeTableName(name), columns, extraConfig);
};
return pgTable;
};
const pgTableCreatorWithSchema = (
customizeTableName: (name: string) => string,
) => {
const pgTable: PgTableFn<string> = (name, columns, extraConfig) => {
// @ts-expect-error: columns can be object or callback, overload mismatch
return envSchema.table(customizeTableName(name), columns, extraConfig);
};
return pgTable;
};

Did you find this page helpful?