// Re-runnable dev seed data. Run with: wrnexus db seed
// Every seeded user has the password "password123" for local testing.
import { hashPassword } from "@wrnexus/core";
import type { Db } from "@wrnexus/db";

export default async function seed(db: Db): Promise<void> {
  const passwordHash = await hashPassword("password123");
  await db.exec("DELETE FROM users");
  const rows: [string, string, number][] = [
    ["ada@wire.dev", "Ada Lovelace", 1],
    ["grace@wire.dev", "Grace Hopper", 1],
    ["linus@wire.dev", "Linus Torvalds", 0],
    ["margaret@wire.dev", "Margaret Hamilton", 1],
  ];
  for (const [email, name, active] of rows) {
    await db.exec("INSERT INTO users (email, name, active, passwordHash) VALUES (?, ?, ?, ?)", [
      email,
      name,
      active,
      passwordHash,
    ]);
  }
}
