Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a "dontDrop" property in shared config to define tables not to be dropped #847

Closed
wants to merge 6 commits into from
9 changes: 8 additions & 1 deletion src/Dialects/Mssql.ts
Expand Up @@ -74,7 +74,14 @@ export class MssqlDialect implements DialectContract {
EXEC sp_executesql @sql;
`)

await this.client.rawQuery(`EXEC sp_MSforeachtable 'DROP TABLE \\?';`)
const ignoredTables = (this.config.wipe?.ignoreTables || [])
.map((table) => `"${table}"`)
.join(', ')

await this.client.rawQuery(`
EXEC sp_MSforeachtable 'DROP TABLE \\?',
@whereand='AND o.Name NOT IN (${ignoredTables || '""'})'
`)
}

public async getAllViews(): Promise<string[]> {
Expand Down