(
db: MySqlDatabase<any, any>,
schema: { [key: string]: MySqlTable },
)
| 865 | |
| 866 | // MySql----------------------------------------------------------------------------------------------------- |
| 867 | const resetMySql = async ( |
| 868 | db: MySqlDatabase<any, any>, |
| 869 | schema: { [key: string]: MySqlTable }, |
| 870 | ) => { |
| 871 | const tablesToTruncate = Object.entries(schema).map(([_tsTableName, table]) => { |
| 872 | const dbTableName = getTableName(table); |
| 873 | return dbTableName; |
| 874 | }); |
| 875 | |
| 876 | await db.execute(sql.raw('SET FOREIGN_KEY_CHECKS = 0;')); |
| 877 | |
| 878 | for (const tableName of tablesToTruncate) { |
| 879 | const sqlQuery = `truncate \`${tableName}\`;`; |
| 880 | await db.execute(sql.raw(sqlQuery)); |
| 881 | } |
| 882 | |
| 883 | await db.execute(sql.raw('SET FOREIGN_KEY_CHECKS = 1;')); |
| 884 | }; |
| 885 | |
| 886 | const filterMysqlTables = (schema: { |
| 887 | [key: string]: |
no test coverage detected