2
0

🧑‍💻 Improve env variables type safety and management (#718)

Closes #679
This commit is contained in:
Baptiste Arnaud
2023-08-28 09:13:53 +02:00
committed by GitHub
parent a23a8c4456
commit 786e5cb582
148 changed files with 1550 additions and 1293 deletions

View File

@@ -1,11 +1,6 @@
import { exec } from 'child_process'
import { join, relative } from 'path'
require('dotenv').config({
override: true,
path: join(__dirname, `../.env`),
})
const postgesqlSchemaPath = relative(
process.cwd(),
join(__dirname, `../postgresql/schema.prisma`)
@@ -34,13 +29,13 @@ export const executePrismaCommand = (command: string, options?: Options) => {
executeCommand(`${command} --schema ${mysqlSchemaPath}`)
}
if (databaseUrl?.startsWith('postgresql://')) {
if (databaseUrl?.startsWith('postgres')) {
console.log('Executing for PostgreSQL schema')
executeCommand(`${command} --schema ${postgesqlSchemaPath}`)
}
if (process.env.DATABASE_URL?.startsWith('postgres://')) {
console.error('PostgreSQL `DATABASE_URL` should start with postgresql://')
console.error('PostgreSQL `DATABASE_URL` should start with postgres')
process.exit(1)
}
}

View File

@@ -1,4 +1,4 @@
import { executePrismaCommand } from './executeCommand'
if (process.env.DATABASE_URL?.startsWith('postgresql://'))
if (process.env.DATABASE_URL?.startsWith('postgres'))
executePrismaCommand('prisma migrate deploy')

View File

@@ -1,4 +1,4 @@
import { executePrismaCommand } from './executeCommand'
if (process.env.DATABASE_URL?.startsWith('postgresql://'))
if (process.env.DATABASE_URL?.startsWith('postgres'))
executePrismaCommand('prisma migrate dev --create-only')