Drizzle-kit migrate
I got this error running the migration on a postgresql database hosted on supabase in local:
this is my config.ts
Attached is my sql migration, I tested the sql in raw and It works, So I'm assuming is the driver or idk.
❯ pnpm drizzle-kit migrate --config src/config.ts
drizzle-kit: v0.22.7
drizzle-orm: v0.31.2
Custom config path was provided, using 'src/config.ts'
Reading config file '/home/copydataai/Documents/Personal/order-manager/packages/db/src/config.ts'
Error Please provide required params for Postgres driver:
[✓] url: 'postgres://postgres:my-password@localhost:5432/order-manager'
❯ pnpm drizzle-kit migrate --config src/config.ts
drizzle-kit: v0.22.7
drizzle-orm: v0.31.2
Custom config path was provided, using 'src/config.ts'
Reading config file '/home/copydataai/Documents/Personal/order-manager/packages/db/src/config.ts'
Error Please provide required params for Postgres driver:
[✓] url: 'postgres://postgres:my-password@localhost:5432/order-manager'
import type { Config } from "drizzle-kit";
import { createEnv } from "@t3-oss/env-core";
import * as z from "zod";
const env = createEnv({
server: {
DB_HOST: z.string(),
DB_PORT: z.string(),
DB_NAME: z.string(),
DB_USERNAME: z.string(),
DB_PASSWORD: z.string(),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});
// Push requires SSL so use URL instead of username/password
export const connectionStr = new URL(
`postgres://${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}`,
);
connectionStr.username = env.DB_USERNAME;
connectionStr.password = env.DB_PASSWORD;
export default {
schema: ["./src/schema/*"],
driver: "pg",
dialect: "postgresql",
dbCredentials: { url: connectionStr.href },
out: "./drizzle",
} satisfies Config;
import type { Config } from "drizzle-kit";
import { createEnv } from "@t3-oss/env-core";
import * as z from "zod";
const env = createEnv({
server: {
DB_HOST: z.string(),
DB_PORT: z.string(),
DB_NAME: z.string(),
DB_USERNAME: z.string(),
DB_PASSWORD: z.string(),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});
// Push requires SSL so use URL instead of username/password
export const connectionStr = new URL(
`postgres://${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}`,
);
connectionStr.username = env.DB_USERNAME;
connectionStr.password = env.DB_PASSWORD;
export default {
schema: ["./src/schema/*"],
driver: "pg",
dialect: "postgresql",
dbCredentials: { url: connectionStr.href },
out: "./drizzle",
} satisfies Config;
1 Reply
I tried with params and still the same:
config.ts
❯ pnpm drizzle-kit introspect --config=src/config.ts
drizzle-kit: v0.22.8
drizzle-orm: v0.31.2
Custom config path was provided, using 'src/config.ts'
Reading config file '/home/copydataai/Documents/Personal/order-manager/packages/db/src/config.ts'
Error Please provide required params for Postgres driver:
[✓] host: 'localhost'
[✓] port: '5432'
[✓] user: 'postgres'
[✓] password: 'my-password'
[✓] database: 'order-manager'
[✓] ssl: 'reject'
❯ pnpm drizzle-kit introspect --config=src/config.ts
drizzle-kit: v0.22.8
drizzle-orm: v0.31.2
Custom config path was provided, using 'src/config.ts'
Reading config file '/home/copydataai/Documents/Personal/order-manager/packages/db/src/config.ts'
Error Please provide required params for Postgres driver:
[✓] host: 'localhost'
[✓] port: '5432'
[✓] user: 'postgres'
[✓] password: 'my-password'
[✓] database: 'order-manager'
[✓] ssl: 'reject'
import type { Config } from "drizzle-kit";
import { createEnv } from "@t3-oss/env-core";
import * as z from "zod";
const env = createEnv({
server: {
DB_HOST: z.string(),
DB_PORT: z.string(),
DB_NAME: z.string(),
DB_USERNAME: z.string(),
DB_PASSWORD: z.string(),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});
// Push requires SSL so use URL instead of username/password
export const connectionStr = new URL(
`postgres://${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}`,
);
connectionStr.username = env.DB_USERNAME;
connectionStr.password = env.DB_PASSWORD;
export default {
schema: ["./src/schema/*"],
driver: "pg",
dialect: "postgresql",
dbCredentials: {
host: env.DB_HOST,
port: env.DB_PORT,
user: env.DB_USERNAME,
password: env.DB_PASSWORD,
database: env.DB_NAME,
ssl: "reject",
},
out: "./drizzle",
strict: true,
introspect: {
casing: "camel",
},
} satisfies Config;
import type { Config } from "drizzle-kit";
import { createEnv } from "@t3-oss/env-core";
import * as z from "zod";
const env = createEnv({
server: {
DB_HOST: z.string(),
DB_PORT: z.string(),
DB_NAME: z.string(),
DB_USERNAME: z.string(),
DB_PASSWORD: z.string(),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});
// Push requires SSL so use URL instead of username/password
export const connectionStr = new URL(
`postgres://${env.DB_HOST}:${env.DB_PORT}/${env.DB_NAME}`,
);
connectionStr.username = env.DB_USERNAME;
connectionStr.password = env.DB_PASSWORD;
export default {
schema: ["./src/schema/*"],
driver: "pg",
dialect: "postgresql",
dbCredentials: {
host: env.DB_HOST,
port: env.DB_PORT,
user: env.DB_USERNAME,
password: env.DB_PASSWORD,
database: env.DB_NAME,
ssl: "reject",
},
out: "./drizzle",
strict: true,
introspect: {
casing: "camel",
},
} satisfies Config;