i hyperfocused and here is v1
This commit is contained in:
parent
8f43e6a6a9
commit
4090fd621e
34 changed files with 4135 additions and 22 deletions
23
packages/database/src/main.ts
Normal file
23
packages/database/src/main.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import { resolve } from "node:path";
|
||||
import pg from "pg";
|
||||
import * as schema from "./schema.ts";
|
||||
|
||||
const client = new pg.Client({
|
||||
host: process.env.DB_HOST,
|
||||
port: Number(process.env.DB_PORT),
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
export const database = drizzle(client, { schema });
|
||||
await migrate(database, {
|
||||
migrationsFolder: resolve(import.meta.dirname, "../migrations"),
|
||||
});
|
||||
|
||||
export * as Drizzle from "drizzle-orm";
|
||||
export * as Schema from "./schema.ts";
|
||||
10
packages/database/src/schema.ts
Normal file
10
packages/database/src/schema.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { bigint, pgTable } from "drizzle-orm/pg-core";
|
||||
|
||||
export const servers = pgTable("servers", {
|
||||
id: bigint("id", { mode: "bigint" }).primaryKey(),
|
||||
channel: bigint("channel", { mode: "bigint" }).notNull(),
|
||||
role: bigint("role", { mode: "bigint" }),
|
||||
});
|
||||
|
||||
export type Server = typeof servers.$inferSelect;
|
||||
export type NewServer = typeof servers.$inferInsert;
|
||||
Loading…
Add table
Add a link
Reference in a new issue