initial install
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import "dotenv/config";
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import postgres from "postgres";
|
||||
import { users, clients, documents } from "../src/lib/db/schema";
|
||||
import { users } from "../src/lib/db/schema";
|
||||
import bcrypt from "bcryptjs";
|
||||
import { inArray } from "drizzle-orm";
|
||||
|
||||
const client = postgres(process.env.DATABASE_URL!);
|
||||
const db = drizzle({ client });
|
||||
@@ -22,35 +21,6 @@ async function seed() {
|
||||
|
||||
console.log(`Seeded agent account: ${email}`);
|
||||
|
||||
// Seed clients
|
||||
await db.insert(clients).values([
|
||||
{ name: "Sarah Johnson", email: "sarah.j@example.com" },
|
||||
{ name: "Mike Torres", email: "m.torres@example.com" },
|
||||
]).onConflictDoNothing();
|
||||
|
||||
console.log("Seeded clients: Sarah Johnson, Mike Torres");
|
||||
|
||||
// Query back seeded clients to get their IDs
|
||||
const [sarah, mike] = await db
|
||||
.select({ id: clients.id })
|
||||
.from(clients)
|
||||
.where(inArray(clients.email, ["sarah.j@example.com", "m.torres@example.com"]))
|
||||
.orderBy(clients.createdAt);
|
||||
|
||||
// Seed placeholder documents
|
||||
if (sarah && mike) {
|
||||
await db.insert(documents).values([
|
||||
{ name: "Purchase Agreement - 842 Maple Dr", clientId: sarah.id, status: "Signed", sentAt: new Date("2026-02-15") },
|
||||
{ name: "Seller Disclosure - 842 Maple Dr", clientId: sarah.id, status: "Signed", sentAt: new Date("2026-02-14") },
|
||||
{ name: "Buyer Rep Agreement", clientId: mike.id, status: "Sent", sentAt: new Date("2026-03-10") },
|
||||
{ name: "Purchase Agreement - 1205 Oak Ave", clientId: mike.id, status: "Draft", sentAt: null },
|
||||
]).onConflictDoNothing();
|
||||
|
||||
console.log("Seeded 4 placeholder documents");
|
||||
} else {
|
||||
console.log("Skipping documents seed — clients not found");
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user