Skip to content

Commit

Permalink
improvement: drop types, views, and tables if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Alyxsqrd authored Apr 6, 2022
1 parent 7ced2c2 commit 5e2cebc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Dialects/Pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class PgDialect implements DialectContract {
const tables = await this.getAllTables(schemas)
if (!tables.length) return

await this.client.rawQuery(`DROP table ${tables.join(',')} CASCADE;`)
await this.client.rawQuery(`DROP TABLE IF EXISTS "${tables.join('", "')}" CASCADE;`)
}

/**
Expand All @@ -100,7 +100,7 @@ export class PgDialect implements DialectContract {
const views = await this.getAllViews(schemas)
if (!views.length) return

await this.client.rawQuery(`DROP view ${views.join(',')} CASCADE;`)
await this.client.rawQuery(`DROP VIEW IF EXISTS "${views.join('", "')}" CASCADE;`)
}

/**
Expand All @@ -110,7 +110,7 @@ export class PgDialect implements DialectContract {
const types = await this.getAllTypes(schemas)
if (!types.length) return

await this.client.rawQuery(`DROP type ${types.join(',')};`)
await this.client.rawQuery(`DROP TYPE IF EXISTS "${types.join('", "')}" CASCADE;`)
}

/**
Expand Down

0 comments on commit 5e2cebc

Please sign in to comment.