Browse Source
Enhance the environment configuration for the SQLite database by adjusting the handling of the DATABASE_URL to ensure correct file path resolution based on the NODE_ENV variable. Modify the temporary working directory logic to correctly set paths for both production and development environments, improving overall path management.feat/multitenant-hub
3 changed files with 15 additions and 1 deletions
Binary file not shown.
@ -1,4 +1,18 @@ |
|||
|
|||
import { config } from 'dotenv'; |
|||
import path from 'path'; |
|||
|
|||
config({ path: '../../.env' }); |
|||
|
|||
const tempCwd = process.env.NODE_ENV === 'production' |
|||
? path.resolve(process.cwd(), 'packages/drizzle-pkg') |
|||
: process.cwd(); |
|||
|
|||
let dbUrl = process.env.DATABASE_URL; |
|||
if (dbUrl && dbUrl.startsWith('file:')) { |
|||
let filePath = dbUrl.slice(5); |
|||
if (!path.isAbsolute(filePath)) { |
|||
filePath = path.resolve(tempCwd, filePath); |
|||
process.env.DATABASE_URL = 'file:' + filePath; |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue