Migration generation error

Hey everyone, I am new to drizzle and my use case is drizzle with mysql database using plain javascript. I have gone over the Drizzle documentations, as well as posts online to tailor the implementations to my use case. When I ran the drizzle-kit migrate command, I got the error
No config path provided, using default 'drizzle.config.js'
No config path provided, using default 'drizzle.config.js'
without creating the migration folder except for one time out of the many times i have ran that command. However, i deleted the migration folder that one time it worked because i thought something went wrong and wanted to retry. But now, I just keep getting this error with no other information to work with on sorting out the issue
21 Replies
Luxaritas
Luxaritas5w ago
drizzle-kit migrate only applies migrations. drizzle-kit generate is what creates the migrations
Tamarah
TamarahOP5w ago
yes... the generate command is what is giving the error without generating the migrations folder Hi @Luxaritas , so I had assistance from a friend that makes use of an older version of the drizzle-orm and the drizzle-kit that suggested I downgrade to the version he uses just to test. I made use of
"drizzle-orm": "^0.30.10",
"drizzle-kit": "^0.21.1"
"drizzle-orm": "^0.30.10",
"drizzle-kit": "^0.21.1"
as suggested, then attempted generation and migration without changing anything else in my code and it worked, which makes me wonder if it is a version issue. So is it possible that either I need to update code somewhere to accommodate the latest versions of the drizzle-orm and drizzle-kit and I don't know how to do it or the latest versions might have unexpected issue not reported yet?
Luxaritas
Luxaritas5w ago
Hm, as far as I know that error isn’t really an error - it’s just notifying you of which config file its using. So it’s a little hard to know exactly what’s going wrong. It might help if you’re able to provide a minimum reproduction (eg in a GitHub repo)
Tamarah
TamarahOP5w ago
okay... so the current code i have is in a private repo because it is for work. So maybe , what i will do is create a personal use case project and then share the code with you.
Luxaritas
Luxaritas5w ago
Yeah as I said, minimum reproduction - ideally you can get it down to eg a drizzle schema with like one table and one field, a package.json with drizzle-orm/drizzl-kit, and nothing else 🙂
Tamarah
TamarahOP5w ago
Okay, no problem
Tamarah
TamarahOP4w ago
GitHub
GitHub - 7amarah/drizzle-orm-with-mysql
Contribute to 7amarah/drizzle-orm-with-mysql development by creating an account on GitHub.
Tamarah
TamarahOP4w ago
also, if I may ask, how do you close a connection to the database after each database query. I got this error today:
Can't add new command when connection is in closed state
Can't add new command when connection is in closed state
Luxaritas
Luxaritas4w ago
This is up to your DB driver, afaik drizzle doesn't manage this directly. You most likely won't want to close connections after each query though, as that adds a lot of overhead to recrete the connections on each query (typically you'll even create a connection pool which opens up a bunch of connections which stick around long-term, then as queries are executed they use available connections from the pool)
Tamarah
TamarahOP4w ago
oh okay, i was asking because the drizzle documentation suggests
For the built in migrate function with DDL migrations we and drivers strongly encourage you to use single client connection.
For the built in migrate function with DDL migrations we and drivers strongly encourage you to use single client connection.
so I am currently using the single client connection and from what I have gathered so far online, I thought maybe the connection could have been the reason for the new error I stated that I got today
Luxaritas
Luxaritas4w ago
I assume that means when instantiating drizzle with the intention of using migrate(), use eg mysql.createConnection rather than instantiating a connection pool Back to this. I've cloned the repo, updated drizzle-orm and drizzke-kit to latest, then run drizzle-kit generate and get the following:
Luxaritas
Luxaritas4w ago
Unless this is because I haven't actually spun up a mysql instance This is odd though, I don't know why itd complain about mysql2 Ah you don't actually have to specify the driver in this case Also, needed to change the schema path to remove api/
Luxaritas
Luxaritas4w ago
Now running drizzle-kit generate works fine
No description
Tamarah
TamarahOP4w ago
I am more inclined to agree with your last reply because it seems to be complaining about the driver wait, you used mysql database... made no changes to the db connection file or the drizzle.config.js file and it worked
Luxaritas
Luxaritas4w ago
Yeah so the status is: - with [email protected] and [email protected] - with driver removed from drizzle.config.js - with schema changed to "./models/schema.js" in drizzle.config.js Running drizzle-kit generate works
Tamarah
TamarahOP4w ago
okay let me check it out
Luxaritas
Luxaritas4w ago
I'll also note I'm using node v20.17.0 if that matters for some reason
Tamarah
TamarahOP4w ago
i will check oh okay... I am using node v20.14.0... so could it matter?
Luxaritas
Luxaritas4w ago
Shouldn't
Tamarah
TamarahOP4w ago
It is hard to believe that my adding driver to the drizzle.config.js file was the main issue. I adjusted the code to my actual project and it generated thank you so much Oh okay, I re-read this reply and i get now. Thank you so much
Want results from more Discord servers?
Add your server