Skip to content

Commit

Permalink
feat: add truncateTables
Browse files Browse the repository at this point in the history
  • Loading branch information
wielopolski committed Nov 7, 2024
1 parent 6a567fb commit e317995
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions apps/api/src/storage/seed/trancateTables.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as dotenv from "dotenv";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

import { seedTruncateAllTables } from "./seed-helpers";

import type { DatabasePg } from "../../common";

dotenv.config({ path: "./.env" });

if (!("DATABASE_URL" in process.env)) {
throw new Error("DATABASE_URL not found on .env");
}

const connectionString = process.env.DATABASE_URL!;
const sql = postgres(connectionString);
const db = drizzle(sql) as DatabasePg;

async function seed() {
await seedTruncateAllTables(db);
}

export default seed;

0 comments on commit e317995

Please sign in to comment.