Last active
July 1, 2024 17:50
-
-
Save capaj/294dea9f66ba3347891612e5c8c1866c to your computer and use it in GitHub Desktop.
drizzle-utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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