[BUG]: drizzle-kit push:mysql throws error with only connectionString
Problem
What version of `drizzle-orm` are you using? 0.26.1 What version of `drizzle-kit` are you using? 0.18.1 Describe the Bug When I try to migrate (push) my schema to my DB it throws an error `Error: Either `connectionString` or `host, port, etc.` params be provided in config file`. [code block] [code block] However I specified the connectionString... Am I doing something wrong here? Expected behavior It should push to db if I declared connectionString Environment & setup _No response_
Error Output
error `Error: Either `connectionString` or `host, port, etc.` params be provided in config file`.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix connectionString issue in drizzle-kit migration
The error occurs because the drizzle-kit migration process expects a specific format for the connection string or additional parameters (host, port, etc.) to be provided in the configuration file. The provided connection string may not be recognized due to formatting issues or missing required parameters.
Awaiting Verification
Be the first to verify this fix
- 1
Verify connectionString format
Ensure that the connectionString is correctly formatted according to the database requirements. It should include all necessary components such as username, password, host, port, and database name.
typescriptconst connectionString = 'mysql://user:password@localhost:3306/database'; - 2
Check configuration file
Open your drizzle-kit configuration file (e.g., drizzle.config.ts) and confirm that the connectionString is correctly specified. Ensure there are no typos or syntax errors.
typescriptexport default { connectionString: 'mysql://user:password@localhost:3306/database' }; - 3
Update drizzle-kit version
Consider updating drizzle-kit to the latest version if you are not using the latest one. This can resolve compatibility issues and bugs that may exist in older versions.
bashnpm install drizzle-kit@latest - 4
Test migration command
Run the migration command again after making the above changes to see if the issue is resolved. Use the command: `npx drizzle-kit push:mysql`.
bashnpx drizzle-kit push:mysql - 5
Fallback to host/port parameters
If the issue persists, as a temporary workaround, specify the database connection using host, port, username, and password instead of the connectionString.
typescriptexport default { host: 'localhost', port: 3306, user: 'user', password: 'password', database: 'database' };
Validation
Confirm the fix worked by successfully running the migration command without errors. The database schema should be updated as expected.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep