MCPcopy
hub / github.com/drizzle-team/drizzle-orm / resetPostgres

Function resetPostgres

drizzle-seed/src/index.ts:482–494  ·  view source on GitHub ↗
(
	db: PgDatabase<any, any>,
	pgTables: { [key: string]: PgTable },
)

Source from the content-addressed store, hash-verified

480
481// Postgres-----------------------------------------------------------------------------------------------------------
482const resetPostgres = async (
483 db: PgDatabase<any, any>,
484 pgTables: { [key: string]: PgTable },
485) => {
486 const tablesToTruncate = Object.entries(pgTables).map(([_, table]) => {
487 const config = getPgTableConfig(table);
488 config.schema = config.schema === undefined ? 'public' : config.schema;
489
490 return `"${config.schema}"."${config.name}"`;
491 });
492
493 await db.execute(sql.raw(`truncate ${tablesToTruncate.join(',')} cascade;`));
494};
495
496const filterPgSchema = (schema: {
497 [key: string]:

Callers 1

resetFunction · 0.85

Calls 1

executeMethod · 0.45

Tested by

no test coverage detected