2026-03-19 13:30:52 -06:00
|
|
|
import "dotenv/config";
|
2026-03-19 14:00:32 -06:00
|
|
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
|
|
|
import postgres from "postgres";
|
2026-03-19 13:30:52 -06:00
|
|
|
import { users } from "../src/lib/db/schema";
|
|
|
|
|
import bcrypt from "bcryptjs";
|
|
|
|
|
|
2026-03-19 14:00:32 -06:00
|
|
|
const client = postgres(process.env.DATABASE_URL!);
|
|
|
|
|
const db = drizzle({ client });
|
2026-03-19 13:30:52 -06:00
|
|
|
|
|
|
|
|
async function seed() {
|
|
|
|
|
const email = process.env.AGENT_EMAIL;
|
|
|
|
|
const password = process.env.AGENT_PASSWORD;
|
|
|
|
|
|
|
|
|
|
if (!email || !password) {
|
|
|
|
|
throw new Error("AGENT_EMAIL and AGENT_PASSWORD env vars are required");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const passwordHash = await bcrypt.hash(password, 12);
|
|
|
|
|
|
|
|
|
|
await db.insert(users).values({ email, passwordHash }).onConflictDoNothing();
|
|
|
|
|
|
|
|
|
|
console.log(`Seeded agent account: ${email}`);
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seed().catch((err) => {
|
|
|
|
|
console.error(err);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|