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

[FEATURE]: allow to use ssl at dbCredentials with url #3802

Open
1 task done
kravetsone opened this issue Dec 18, 2024 · 0 comments
Open
1 task done

[FEATURE]: allow to use ssl at dbCredentials with url #3802

kravetsone opened this issue Dec 18, 2024 · 0 comments
Labels
drizzle/kit enhancement New feature or request

Comments

@kravetsone
Copy link
Contributor

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

For now in typings it union type of definition dbCredentials

{
    dialect: Verify<Dialect, 'postgresql'>;
    dbCredentials: ({
        host: string;
        port?: number;
        user?: string;
        password?: string;
        database: string;
        ssl?: boolean | 'require' | 'allow' | 'prefer' | 'verify-full' | ConnectionOptions;
    } & {}) | {
        url: string;
    };
}

I want to use both url & ssl keys

import type { Config } from "drizzle-kit"

export default {
  schema: "./src/db/schema.ts",
  out: "./drizzle",
  dialect: "postgresql",
  dbCredentials: {
    url: process.env.DATABASE_URL as string
  }
} satisfies Config

like in postgres client initialization

const client = postgres(process.env.DATABASE_URL as string, {
	ssl: "require",
});
export const db = drizzle(client);

workaround is:

import type { Config } from "drizzle-kit";

const url = new URL(process.env.DATABASE_URL as string);

if (process.env.USE_SSL) {
	url.searchParams.append("sslmode", "require");
	url.searchParams.append("ssl", "true");
}

export default {
	schema: "./src/db/schema.ts",
	out: "./drizzle",
	dialect: "postgresql",
	casing: "snake_case",
	dbCredentials: {
		url: url.toString(),
	},
} satisfies Config;
@kravetsone kravetsone added the enhancement New feature or request label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drizzle/kit enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants