Is there a way for me to run `npx prisma db push -...
# prisma-client
l
Is there a way for me to run
npx prisma db push --preview-feature --force-reset
from the js PrismaClient? I want to use it to clear my database after I run tests. I suppose I can always use spawn to run the command but if there is a js way to achieve the same thing I’d prefer that.
d
Copy code
import { execSync } from 'child_process'


const prismaBinary = join(__dirname, '..', 'node_modules', '.bin', 'prisma')

execSync(`${prismaBinary} migrate deploy --preview-feature`, {
        env: {
          ...process.env,
          DATABASE_URL: 'SOME_TEST_URL',
        },
      })
šŸ‘€ 1
l
Thanks for the guidance šŸ™‚ I was hoping there would be a client method hidden somewhere to achieve the same thing, maybe I was over thinking it.
r
i recommend against accessing prisma via node modules. instead, just use:
execSync('npm prisma migrate deploy -etc')
or
execSync('yarn prisma migrate deploy -etc')
as .bin/prisma doesn't have the same context as npm/yarn prisma
šŸ™Œ 1