pecko0326
pecko0326
Explore posts from servers
DTDrizzle Team
Created by pecko0326 on 8/9/2024 in #help
MySQL Driver keeps asking for 'password' parameter
When trying to connect to my local MySQL database, to which I do not have any password setup, I get an error when running drizzle-kit migrate command. Here's my drizzle.config.ts file, I double checked the docs but I can't seem to figure out what I'm missing out:
import { defineConfig } from "drizzle-kit";

if (!process.env.DB_NAME) {
throw new Error("ERROR: 'DB_NAME' env is not setup correctly!");
}

if (!process.env.DB_HOST) {
throw new Error("ERROR: 'DB_HOST' env is not setup correctly!");
}

export default defineConfig({
schema: "./src/db/schema/*",
dialect: "mysql",
out: "./src/db/migrations",
migrations: {
prefix: "timestamp",
},
dbCredentials: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
},
strict: true,
verbose: true,
});
import { defineConfig } from "drizzle-kit";

if (!process.env.DB_NAME) {
throw new Error("ERROR: 'DB_NAME' env is not setup correctly!");
}

if (!process.env.DB_HOST) {
throw new Error("ERROR: 'DB_HOST' env is not setup correctly!");
}

export default defineConfig({
schema: "./src/db/schema/*",
dialect: "mysql",
out: "./src/db/migrations",
migrations: {
prefix: "timestamp",
},
dbCredentials: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
},
strict: true,
verbose: true,
});
In my .env file I have the fields setup, and the DB_PASSWORD variable has an empty string value as there's no password associated with the database user. The error that I get is Please provide required params for MySQL driver: and the password field is marked with an X and an empty string value.
2 replies
DTDrizzle Team
Created by pecko0326 on 3/14/2024 in #help
How to delete multiple rows whose value is contained in a list of values, at once?
If I want to delete multiple rows whose value (e.g. 'key') is included in a list of values, in raw SQL I can do something like this:
DELETE FROM example_table WHERE example_table.key IN (key1, key2, ...)
DELETE FROM example_table WHERE example_table.key IN (key1, key2, ...)
But, that seems to not be working correctly when using it in Drizzle, or I'm doing something completely wrong. Using MySQL. Here's my code:
const keysToDelete = ['key-1', 'key-2'];
await db
.delete(exampleTable)
.where(sql`${exampleTable.key} IN (${keysToDelete})`);
const keysToDelete = ['key-1', 'key-2'];
await db
.delete(exampleTable)
.where(sql`${exampleTable.key} IN (${keysToDelete})`);
I tried also joining the keys to delete as a single string using keysToDelete.join(",") but that also didn't work. The entries are not being removed from the database. However if I want to check against a single value within the IN (...) clause, it works fine.
2 replies
TTCTheo's Typesafe Cult
Created by pecko0326 on 3/13/2024 in #questions
Uploadthing Deleting files
Has anything changed regarding the provided Open API that we can use to send requests to from our own servers when we want to delete files? Previously it worked fine, sent the requests and files were being deleted from Uploadthing without providing the X-Uploadthing-Version header. But now for some reason, I must include that header in order for my requests to actually delete the targeted file(s) based on the provided file keys. Is this something that was changed recently, and if so, will we need to update the version anytime there's an update to the Uploadthing's API?
2 replies