i hyperfocused and here is v1

This commit is contained in:
Rose 2024-04-19 00:15:20 -04:00
parent 8f43e6a6a9
commit 4090fd621e
No known key found for this signature in database
34 changed files with 4135 additions and 22 deletions

View file

@ -0,0 +1,4 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"extends": ["@datamine/config/biome"]
}

View file

@ -0,0 +1,6 @@
import type { Config } from "drizzle-kit";
export default {
schema: "./src/schema.ts",
out: "./migrations",
} satisfies Config;

View file

@ -0,0 +1,34 @@
{
"name": "@datamine/database",
"packageManager": "yarn@4.1.1",
"private": true,
"type": "module",
"main": "./dist/main.js",
"module": "./dist/main.js",
"types": "./dist/main.d.ts",
"exports": {
"import": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
}
},
"devDependencies": {
"@biomejs/biome": "1.6.4",
"@datamine/config": "workspace:*",
"@types/node": "20.12.7",
"pkgroll": "2.0.2",
"tsx": "4.7.2",
"typescript": "5.4.5"
},
"scripts": {
"lint": "biome check ./src/**/*",
"build": "pkgroll",
"drizzle": "drizzle-kit generate:pg"
},
"dependencies": {
"@types/pg": "8.11.5",
"drizzle-kit": "0.20.14",
"drizzle-orm": "0.30.8",
"pg": "8.11.5"
}
}

View 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";

View 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;

View file

@ -0,0 +1,5 @@
{
"extends": "@datamine/config/typescript",
"exclude": ["node_modules"],
"include": ["src"]
}