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

Function reset

drizzle-seed/src/index.ts:441–479  ·  view source on GitHub ↗
(db: DB, schema: SCHEMA)

Source from the content-addressed store, hash-verified

439 * ```
440 */
441export async function reset<
442 DB extends
443 | PgDatabase<any, any>
444 | MySqlDatabase<any, any, any, any>
445 | BaseSQLiteDatabase<any, any>,
446 SCHEMA extends {
447 [key: string]:
448 | PgTable
449 | PgSchema
450 | MySqlTable
451 | MySqlSchema
452 | SQLiteTable
453 | any;
454 },
455>(db: DB, schema: SCHEMA) {
456 if (is(db, PgDatabase<any, any>)) {
457 const { pgTables } = filterPgSchema(schema);
458
459 if (Object.entries(pgTables).length > 0) {
460 await resetPostgres(db, pgTables);
461 }
462 } else if (is(db, MySqlDatabase<any, any>)) {
463 const { mysqlTables } = filterMysqlTables(schema);
464
465 if (Object.entries(mysqlTables).length > 0) {
466 await resetMySql(db, mysqlTables);
467 }
468 } else if (is(db, BaseSQLiteDatabase<any, any>)) {
469 const { sqliteTables } = filterSqliteTables(schema);
470
471 if (Object.entries(sqliteTables).length > 0) {
472 await resetSqlite(db, sqliteTables);
473 }
474 } else {
475 throw new Error(
476 'The drizzle-seed package currently supports only PostgreSQL, MySQL, and SQLite databases. Please ensure your database is one of these supported types',
477 );
478 }
479}
480
481// Postgres-----------------------------------------------------------------------------------------------------------
482const resetPostgres = async (

Callers 15

mysql.test.tsFile · 0.90
pg.test.tsFile · 0.90
sqlite.test.tsFile · 0.90
mysql.tsFile · 0.90
pg.tsFile · 0.90
sqlite.tsFile · 0.90
mysql.test.tsFile · 0.90
pg.test.tsFile · 0.90
generators.test.tsFile · 0.90

Calls 7

isFunction · 0.90
filterPgSchemaFunction · 0.85
resetPostgresFunction · 0.85
filterMysqlTablesFunction · 0.85
resetMySqlFunction · 0.85
filterSqliteTablesFunction · 0.85
resetSqliteFunction · 0.85

Tested by

no test coverage detected