mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-01-06 04:32:37 +00:00
✨ feat: Prisma instead of drizzle
This commit is contained in:
@@ -3,16 +3,21 @@
|
||||
"module": "src/index.ts",
|
||||
"type": "module",
|
||||
"exports": "./src/index.ts",
|
||||
"scripts": {
|
||||
"generate": "prisma generate",
|
||||
"studio": "bun with-env prisma studio",
|
||||
"push": "bun with-env prisma db push",
|
||||
"with-env": "dotenv -e ../../.env --"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"drizzle-kit": "^0.24.2"
|
||||
"@types/bun": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"drizzle-orm": "^0.33.0",
|
||||
"postgres": "^3.4.4"
|
||||
"@prisma/client": "5.20.0",
|
||||
"dotenv-cli": "^7.4.2",
|
||||
"prisma": "^5.20.0"
|
||||
}
|
||||
}
|
||||
|
||||
38
packages/db/prisma/schema.prisma
Normal file
38
packages/db/prisma/schema.prisma
Normal file
@@ -0,0 +1,38 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum ServerType {
|
||||
STATEFUL
|
||||
STATELESS
|
||||
REVERSE_PROXY
|
||||
}
|
||||
|
||||
model Server {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
address String
|
||||
port Int
|
||||
type ServerType
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
username String @unique
|
||||
password String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
@@ -1,15 +1,5 @@
|
||||
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";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
console.log(process.env.DATABASE_URL);
|
||||
export * from "@prisma/client";
|
||||
|
||||
// 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 });
|
||||
export const prisma = new PrismaClient();
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
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