fix
This commit is contained in:
parent
e29779f052
commit
e86049c06f
|
|
@ -1,6 +1,11 @@
|
||||||
import { $ } from "execa";
|
import { $ } from "execa";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { dirAsync, readAsync, removeAsync, writeAsync } from "fs-jetpack";
|
import {
|
||||||
|
dirAsync,
|
||||||
|
readAsync,
|
||||||
|
removeAsync,
|
||||||
|
writeAsync
|
||||||
|
} from "fs-jetpack";
|
||||||
import { apiContext } from "service-srv";
|
import { apiContext } from "service-srv";
|
||||||
import { deploy } from "utils/deploy";
|
import { deploy } from "utils/deploy";
|
||||||
import { dir } from "utils/dir";
|
import { dir } from "utils/dir";
|
||||||
|
|
@ -74,6 +79,7 @@ export const _ = {
|
||||||
DATABASE_URL: action.url,
|
DATABASE_URL: action.url,
|
||||||
});
|
});
|
||||||
await Bun.write(dir(".env"), env);
|
await Bun.write(dir(".env"), env);
|
||||||
|
await Bun.write(dir("app/db/.env"), env);
|
||||||
}
|
}
|
||||||
return "ok";
|
return "ok";
|
||||||
case "db-gen":
|
case "db-gen":
|
||||||
|
|
@ -88,7 +94,7 @@ export const _ = {
|
||||||
break;
|
break;
|
||||||
case "db-pull":
|
case "db-pull":
|
||||||
{
|
{
|
||||||
const env = await readAsync(dir("app/db/.env"));
|
let env = await readAsync(dir("app/db/.env"));
|
||||||
if (env) {
|
if (env) {
|
||||||
const ENV = parseEnv(env);
|
const ENV = parseEnv(env);
|
||||||
if (typeof ENV.DATABASE_URL === "string") {
|
if (typeof ENV.DATABASE_URL === "string") {
|
||||||
|
|
@ -110,7 +116,7 @@ export const _ = {
|
||||||
try {
|
try {
|
||||||
await Bun.write(
|
await Bun.write(
|
||||||
dir("app/db/.env"),
|
dir("app/db/.env"),
|
||||||
`DATABASE_URL=${process.env.DATABASE_URL}`
|
`DATABASE_URL=${ENV.DATABASE_URL}`
|
||||||
);
|
);
|
||||||
await $({ cwd: dir("app/db") })`bun install`;
|
await $({ cwd: dir("app/db") })`bun install`;
|
||||||
await $({ cwd: dir("app/db") })`bun prisma db pull --force`;
|
await $({ cwd: dir("app/db") })`bun prisma db pull --force`;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ const main = {
|
||||||
console.log("Process Manager running at port:", port);
|
console.log("Process Manager running at port:", port);
|
||||||
|
|
||||||
if (process.env.DATABASE_URL) {
|
if (process.env.DATABASE_URL) {
|
||||||
if (!(await existsAsync(dir("node_modules/.prisma")))) {
|
if (!(await existsAsync(dir("node_modules/.prisma"))) && process.env.DATABASE_URL) {
|
||||||
try {
|
try {
|
||||||
await Bun.write(
|
await Bun.write(
|
||||||
dir("app/db/.env"),
|
dir("app/db/.env"),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
import { Property, createPrismaSchemaBuilder } from "@mrleebo/prisma-ast";
|
import { Property, createPrismaSchemaBuilder } from "@mrleebo/prisma-ast";
|
||||||
import { readAsync } from "fs-jetpack";
|
import { readAsync } from "fs-jetpack";
|
||||||
//@ts-ignore
|
|
||||||
import { Prisma } from "../../app/db/db";
|
|
||||||
import { dir } from "./dir";
|
import { dir } from "./dir";
|
||||||
import { gunzipAsync } from "./gzip";
|
import { gunzipAsync } from "./gzip";
|
||||||
|
|
||||||
|
|
@ -319,6 +317,7 @@ export const execQuery = async (args: DBArg, prisma: any) => {
|
||||||
|
|
||||||
if (Array.isArray(json)) {
|
if (Array.isArray(json)) {
|
||||||
const q = json.shift();
|
const q = json.shift();
|
||||||
|
const Prisma = (await import("../../app/db/db")).Prisma;
|
||||||
return await tableInstance.bind(prisma)(Prisma.sql(q, ...json));
|
return await tableInstance.bind(prisma)(Prisma.sql(q, ...json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue