(db: DB, schema: SCHEMA)
| 439 | * ``` |
| 440 | */ |
| 441 | export 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----------------------------------------------------------------------------------------------------------- |
| 482 | const resetPostgres = async ( |
no test coverage detected