mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-01-31 14:57:49 +00:00
✨ feat: Initialized project
This commit is contained in:
15
packages/db/src/index.ts
Normal file
15
packages/db/src/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import "dotenv/config";
|
||||
import { drizzle } from "drizzle-orm/postgres-js";
|
||||
import { migrate } from "drizzle-orm/postgres-js/migrator";
|
||||
import postgres from "postgres";
|
||||
import * as schema from "./schema";
|
||||
|
||||
console.log(process.env.DATABASE_URL);
|
||||
|
||||
// for migrations
|
||||
const migrationClient = postgres(process.env.DATABASE_URL || "", { max: 1 });
|
||||
// migrate(drizzle(migrationClient), ...)
|
||||
|
||||
// for query purposes
|
||||
const queryClient = postgres(process.env.DATABASE_URL || "");
|
||||
export const db = drizzle(queryClient, { schema });
|
||||
13
packages/db/src/schema.ts
Normal file
13
packages/db/src/schema.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {
|
||||
serial,
|
||||
text,
|
||||
timestamp,
|
||||
pgTable,
|
||||
pgSchema,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
export const server = pgTable("server", {
|
||||
id: serial("id"),
|
||||
createdAt: timestamp("created_at"),
|
||||
updatedAt: timestamp("updated_at"),
|
||||
});
|
||||
Reference in New Issue
Block a user