Skip to content

Instantly share code, notes, and snippets.

@capaj
Last active March 10, 2024 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save capaj/294dea9f66ba3347891612e5c8c1866c to your computer and use it in GitHub Desktop.
Save capaj/294dea9f66ba3347891612e5c8c1866c to your computer and use it in GitHub Desktop.
drizzle-utils
import { getTableName, sql } from 'drizzle-orm'
import * as schema from '../src/schema'
import { db } from '../src/db'
const allTableNames = Object.values(schema).map((table) => getTableName(table))
for (const table of allTableNames) {
console.log(`Dropping table ${table}`)
await db.run(sql.raw(`DROP TABLE ${table}`))
}
await db.run(sql.raw('DROP TABLE IF EXISTS __drizzle_migrations'))
await db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment