Add database package with Drizzle schema
Postgres schema via Drizzle ORM for agents, goals, issues, projects, and activity log tables. Includes migration runner, seed script, and Drizzle config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
13
packages/db/src/migrate.ts
Normal file
13
packages/db/src/migrate.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||||
import postgres from "postgres";
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
|
||||
const url = process.env.DATABASE_URL;
|
||||
if (!url) throw new Error("DATABASE_URL is required");
|
||||
|
||||
const sql = postgres(url, { max: 1 });
|
||||
const db = drizzle(sql);
|
||||
|
||||
await migrate(db, { migrationsFolder: new URL("./migrations", import.meta.url).pathname });
|
||||
await sql.end();
|
||||
console.log("Migrations complete");
|
||||
Reference in New Issue
Block a user