fix: realign sqlite path and stabilize client data
This commit is contained in:
@@ -144,6 +144,10 @@ const config = {
|
||||
"fromEnvVar": null,
|
||||
"value": "darwin-arm64",
|
||||
"native": true
|
||||
},
|
||||
{
|
||||
"fromEnvVar": null,
|
||||
"value": "linux-musl-arm64-openssl-3.0.x"
|
||||
}
|
||||
],
|
||||
"previewFeatures": [],
|
||||
@@ -169,8 +173,8 @@ const config = {
|
||||
}
|
||||
}
|
||||
},
|
||||
"inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"../src/generated/client\"\n}\n\ndatasource db {\n provider = \"sqlite\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel Collection {\n id String @id @default(uuid())\n name String\n drawings Drawing[]\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Drawing {\n id String @id @default(uuid())\n name String\n elements String // Stored as JSON string\n appState String // Stored as JSON string\n files String @default(\"{}\") // Stored as JSON string\n preview String? // SVG string for thumbnail\n version Int @default(1)\n collectionId String?\n collection Collection? @relation(fields: [collectionId], references: [id])\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n",
|
||||
"inlineSchemaHash": "e43b17bb99e7f864b5a0f2c54951015f0a3d998329d0577afda58e7c0dee4919",
|
||||
"inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"../src/generated/client\"\n binaryTargets = [\"native\", \"linux-musl-arm64-openssl-3.0.x\"]\n}\n\ndatasource db {\n provider = \"sqlite\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel Collection {\n id String @id @default(uuid())\n name String\n drawings Drawing[]\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Drawing {\n id String @id @default(uuid())\n name String\n elements String // Stored as JSON string\n appState String // Stored as JSON string\n files String @default(\"{}\") // Stored as JSON string\n preview String? // SVG string for thumbnail\n version Int @default(1)\n collectionId String?\n collection Collection? @relation(fields: [collectionId], references: [id])\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n",
|
||||
"inlineSchemaHash": "9864a039193c73ddda01fd51751788fa5729bb0a603a9379a3fa314a4aced64f",
|
||||
"copyEngine": true
|
||||
}
|
||||
config.dirname = '/'
|
||||
|
||||
@@ -145,6 +145,10 @@ const config = {
|
||||
"fromEnvVar": null,
|
||||
"value": "darwin-arm64",
|
||||
"native": true
|
||||
},
|
||||
{
|
||||
"fromEnvVar": null,
|
||||
"value": "linux-musl-arm64-openssl-3.0.x"
|
||||
}
|
||||
],
|
||||
"previewFeatures": [],
|
||||
@@ -170,8 +174,8 @@ const config = {
|
||||
}
|
||||
}
|
||||
},
|
||||
"inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"../src/generated/client\"\n}\n\ndatasource db {\n provider = \"sqlite\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel Collection {\n id String @id @default(uuid())\n name String\n drawings Drawing[]\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Drawing {\n id String @id @default(uuid())\n name String\n elements String // Stored as JSON string\n appState String // Stored as JSON string\n files String @default(\"{}\") // Stored as JSON string\n preview String? // SVG string for thumbnail\n version Int @default(1)\n collectionId String?\n collection Collection? @relation(fields: [collectionId], references: [id])\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n",
|
||||
"inlineSchemaHash": "e43b17bb99e7f864b5a0f2c54951015f0a3d998329d0577afda58e7c0dee4919",
|
||||
"inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n provider = \"prisma-client-js\"\n output = \"../src/generated/client\"\n binaryTargets = [\"native\", \"linux-musl-arm64-openssl-3.0.x\"]\n}\n\ndatasource db {\n provider = \"sqlite\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel Collection {\n id String @id @default(uuid())\n name String\n drawings Drawing[]\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Drawing {\n id String @id @default(uuid())\n name String\n elements String // Stored as JSON string\n appState String // Stored as JSON string\n files String @default(\"{}\") // Stored as JSON string\n preview String? // SVG string for thumbnail\n version Int @default(1)\n collectionId String?\n collection Collection? @relation(fields: [collectionId], references: [id])\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n",
|
||||
"inlineSchemaHash": "9864a039193c73ddda01fd51751788fa5729bb0a603a9379a3fa314a4aced64f",
|
||||
"copyEngine": true
|
||||
}
|
||||
|
||||
@@ -211,6 +215,10 @@ Object.assign(exports, Prisma)
|
||||
// file annotations for bundling tools to include these files
|
||||
path.join(__dirname, "libquery_engine-darwin-arm64.dylib.node");
|
||||
path.join(process.cwd(), "src/generated/client/libquery_engine-darwin-arm64.dylib.node")
|
||||
|
||||
// file annotations for bundling tools to include these files
|
||||
path.join(__dirname, "libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node");
|
||||
path.join(process.cwd(), "src/generated/client/libquery_engine-linux-musl-arm64-openssl-3.0.x.so.node")
|
||||
// file annotations for bundling tools to include these files
|
||||
path.join(__dirname, "schema.prisma");
|
||||
path.join(process.cwd(), "src/generated/client/schema.prisma")
|
||||
|
||||
BIN
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "prisma-client-0eff54f2002515791cbb1f1a5b1632637c7e46544d107e5ff89b7092d9540808",
|
||||
"name": "prisma-client-04007c5051869a2f5298bd562ab2fb60a423747e0d5699dd1a73a4757b2657b6",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"browser": "index-browser.js",
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../src/generated/client"
|
||||
provider = "prisma-client-js"
|
||||
output = "../src/generated/client"
|
||||
binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
|
||||
+22
-4
@@ -12,10 +12,28 @@ import { PrismaClient } from "./generated/client";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
// Ensure DATABASE_URL is absolute to avoid relative path issues with generated client
|
||||
// Point to the same DB file as Prisma CLI (relative to schema.prisma, usually in prisma/ folder)
|
||||
const dbPath = path.resolve(__dirname, "../prisma/dev.db");
|
||||
process.env.DATABASE_URL = `file:${dbPath}`;
|
||||
// Ensure DATABASE_URL always points to an absolute path when using SQLite.
|
||||
// Respect externally provided values and only fall back to the dev database when unset.
|
||||
const backendRoot = path.resolve(__dirname, "../");
|
||||
const defaultDbPath = path.resolve(backendRoot, "prisma/dev.db");
|
||||
const resolveDatabaseUrl = (rawUrl?: string) => {
|
||||
if (!rawUrl || rawUrl.trim().length === 0) {
|
||||
return `file:${defaultDbPath}`;
|
||||
}
|
||||
|
||||
if (!rawUrl.startsWith("file:")) {
|
||||
return rawUrl;
|
||||
}
|
||||
|
||||
const filePath = rawUrl.replace(/^file:/, "");
|
||||
const absolutePath = path.isAbsolute(filePath)
|
||||
? filePath
|
||||
: path.resolve(backendRoot, filePath);
|
||||
|
||||
return `file:${absolutePath}`;
|
||||
};
|
||||
|
||||
process.env.DATABASE_URL = resolveDatabaseUrl(process.env.DATABASE_URL);
|
||||
console.log("Resolved DATABASE_URL:", process.env.DATABASE_URL);
|
||||
|
||||
const app = express();
|
||||
|
||||
Reference in New Issue
Block a user