Fix better-sqlite3 binding for Prisma adapter
- Force SKIP_SQLITE_REBUILD=false in stack.yml - Copy binding to multiple locations including @prisma/client paths - Include version-specific paths for Node.js compiled bindings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e9a658341f
commit
e493ec9d5d
2 changed files with 26 additions and 1 deletions
|
|
@ -128,10 +128,35 @@ try {
|
||||||
const pkgDir = path.dirname(pkgPath)
|
const pkgDir = path.dirname(pkgPath)
|
||||||
const pkg = require(pkgPath)
|
const pkg = require(pkgPath)
|
||||||
const built = path.join(pkgDir, "build", "Release", "better_sqlite3.node")
|
const built = path.join(pkgDir, "build", "Release", "better_sqlite3.node")
|
||||||
|
|
||||||
|
// Copy to bun store
|
||||||
const store = path.join(process.cwd(), "node_modules", ".bun", `better-sqlite3@${pkg.version}`, "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node")
|
const store = path.join(process.cwd(), "node_modules", ".bun", `better-sqlite3@${pkg.version}`, "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node")
|
||||||
fs.mkdirSync(path.dirname(store), { recursive: true })
|
fs.mkdirSync(path.dirname(store), { recursive: true })
|
||||||
fs.copyFileSync(built, store)
|
fs.copyFileSync(built, store)
|
||||||
console.log(`[start-web] better-sqlite3 (v${pkg.version}) copiado para store bun: ${store}`)
|
console.log(`[start-web] better-sqlite3 (v${pkg.version}) copiado para store bun: ${store}`)
|
||||||
|
|
||||||
|
// Copy to @prisma/adapter-better-sqlite3 and @prisma/client locations
|
||||||
|
const nodeVersion = process.version.slice(1).split('.')[0] + '.' + process.version.slice(1).split('.')[1] + '.' + process.version.slice(1).split('.')[2]
|
||||||
|
const adapterPaths = [
|
||||||
|
// Adapter locations
|
||||||
|
path.join(process.cwd(), "node_modules", "@prisma", "adapter-better-sqlite3", "build", "Release", "better_sqlite3.node"),
|
||||||
|
path.join(process.cwd(), "node_modules", "@prisma", "adapter-better-sqlite3", "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node"),
|
||||||
|
// @prisma/client locations that the adapter might be looking at
|
||||||
|
path.join(process.cwd(), "node_modules", "@prisma", "client", "build", "Release", "better_sqlite3.node"),
|
||||||
|
path.join(process.cwd(), "node_modules", "@prisma", "client", "Release", "better_sqlite3.node"),
|
||||||
|
path.join(process.cwd(), "node_modules", "@prisma", "client", "compiled", nodeVersion, "linux", "x64", "better_sqlite3.node"),
|
||||||
|
// Bun store locations
|
||||||
|
path.join(process.cwd(), "node_modules", ".bun", "@prisma-adapter-better-sqlite3@7.0.0", "node_modules", "@prisma", "adapter-better-sqlite3", "node_modules", "better-sqlite3", "build", "Release", "better_sqlite3.node"),
|
||||||
|
]
|
||||||
|
for (const dest of adapterPaths) {
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(path.dirname(dest), { recursive: true })
|
||||||
|
fs.copyFileSync(built, dest)
|
||||||
|
console.log(`[start-web] binding copiado para: ${dest}`)
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore path copy errors
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[start-web] não foi possível copiar binding para .bun store:", error?.message || error)
|
console.error("[start-web] não foi possível copiar binding para .bun store:", error?.message || error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ services:
|
||||||
# Evita apt-get na inicialização porque a imagem já vem com toolchain pronta
|
# Evita apt-get na inicialização porque a imagem já vem com toolchain pronta
|
||||||
SKIP_APT_BOOTSTRAP: "true"
|
SKIP_APT_BOOTSTRAP: "true"
|
||||||
# Sempre revalida/rebuild better-sqlite3 para a runtime atual
|
# Sempre revalida/rebuild better-sqlite3 para a runtime atual
|
||||||
SKIP_SQLITE_REBUILD: "true"
|
SKIP_SQLITE_REBUILD: "false"
|
||||||
# Usado para forçar novo rollout a cada deploy (setado pelo CI)
|
# Usado para forçar novo rollout a cada deploy (setado pelo CI)
|
||||||
RELEASE_SHA: "${RELEASE_SHA:-dev}"
|
RELEASE_SHA: "${RELEASE_SHA:-dev}"
|
||||||
deploy:
|
deploy:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue