Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove neonConfig.fetchConnectionCache is deprecated #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions src/commands/add/orm/drizzle/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export default {
? `url: env.DATABASE_URL,
authToken: env.DATABASE_AUTH_TOKEN`
: provider === "better-sqlite3"
? "url: env.DATABASE_URL"
: provider === "mysql-2" || provider === "planetscale"
? "uri: env.DATABASE_URL"
: "connectionString: env.DATABASE_URL"
? "url: env.DATABASE_URL"
: provider === "mysql-2" || provider === "planetscale"
? "uri: env.DATABASE_URL"
: "connectionString: env.DATABASE_URL"
}${provider === "vercel-pg" ? '.concat("?sslmode=require")' : ""},
}
} satisfies Config;`
Expand Down Expand Up @@ -107,15 +107,12 @@ export const pool = new Pool({
export const db = drizzle(pool);`;
break;
case "neon":
indexTS = `import { neon, neonConfig, NeonQueryFunction } from '@neondatabase/serverless';
indexTS = `import { neon, NeonQueryFunction } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';
import { env } from "${formatFilePath(envMjs, {
removeExtension: false,
prefix: "alias",
})}";

neonConfig.fetchConnectionCache = true;

export const sql: NeonQueryFunction<boolean, boolean> = neon(env.DATABASE_URL);
export const db = drizzle(sql);
`;
Expand Down Expand Up @@ -283,11 +280,9 @@ const db = drizzle(client);
imports = `
import { drizzle } from "drizzle-orm/neon-http";
import { migrate } from "drizzle-orm/neon-http/migrator";
import { neon, neonConfig, NeonQueryFunction } from '@neondatabase/serverless';
import { neon, NeonQueryFunction } from '@neondatabase/serverless';
`;
connectionLogic = `
neonConfig.fetchConnectionCache = true;

const sql: NeonQueryFunction<boolean, boolean> = neon(env.DATABASE_URL);
const db = drizzle(sql);
`;
Expand Down Expand Up @@ -791,10 +786,10 @@ export const createComputer = async (computer: NewComputer) => {
${
driver === "mysql" ? "" : "const [c] = "
} await db.insert(computers).values(newComputer)${
driver === "mysql"
? "\n return { success: true }"
: ".returning();\n return { computer: c }"
}
driver === "mysql"
? "\n return { success: true }"
: ".returning();\n return { computer: c }"
}
} catch (err) {
const message = (err as Error).message ?? "Error, please try again";
console.error(message);
Expand Down Expand Up @@ -827,10 +822,10 @@ export const deleteComputer = async (id: ComputerId) => {
${
driver === "mysql" ? "" : "const [c] = "
}await db.delete(computers).where(eq(computers.id, computerId!))${
driver === "mysql"
? "\n return { success: true };"
: ".returning();\n return { computer: c };"
}
driver === "mysql"
? "\n return { success: true };"
: ".returning();\n return { computer: c };"
}
} catch (err) {
const message = (err as Error).message ?? "Error, please try again"
console.error(message);
Expand Down