Replies: 2 comments 5 replies
We should keep the name that is in the dependencies because
So now it will be mandatory? However, it can be hard to realize later that I need to add the driver to unlock specific config for the driver/vendor I use, so, if it is mandatory, better to be explicit.
There is a case I know that would instantly fail: PGLite (With Maintaining a list of cross-dialect compatibilities may be risky and time-consuming? I would be strict: faster to implement, better configuration (what I set is what I use). |
|
Please add support for Currently (v1.3.0 or v1.3.1) gives error when running with bun bun --bun drizzle-kit pushAnd running without bun drizzle-kit pushTip Hence, can we get a new option in the driver? import { defineConfig } from 'drizzle-kit'
const migrationTableName = 'migrations'
export default defineConfig({
schema: './src/db/schema/*.ts',
out: './drizzle',
dialect: 'sqlite',
dbCredentials: {
url: './data.db',
},
migrations: {
table: migrationTableName,
},
}) |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Drizzle ORM is designed to be dialect specific and used with a particular range of database drivers per dialect. While it lets Drizzle move fast and rapidly add support for whatever new dialects/drivers/databases emerged on the market, it makes it harder for newcomers to onboard.
As of now we're going through a major release of Drizzle Kit and adding support for mostly all drivers available, we decided to sit and talk through how we can make it better.
as of now developers need to specify both
dialectanddriverin the config file. Dialect being either ofpg | mysql | sqliteand this list will be joined bymariadb | cockroachdb | mssql | turso(libsql)and on the other hand we have drivers likenode-pg | postgresjs | neon-serverless | aws-data-api-pg | xataioand that's only for postgres dialect.Drizzle config is meant to be typed and
driverparam presence infersdbCredentialsobject so that you can enjoy typed params experience. While we already have a variety of different drivers, their naming brings even more confusion and you end up with something like this:in that case
driver: "pg"is anode-postgresdriver which is namedpgon the npmwe also have
postgresjsdriver which is namedpostgreson the npm, which will lead to:and it brings confusion, cause you as a developer install
npm i pgbut in our config it will be callednode-pgwhich is how the library is called, or driver will be calledpgand thus another confusion of why do you have to statedialect: pganddriver: pg. Goes the same withpostgresjsdriver which is going to be eitherdialect: pganddriver: postgresordriver: postgresjs.We're aiming move away from the model of
developer passing a driver instance to Drizzle constructorto the knex-like one, to reduce the initial learning curve/complexity for developers to jump into Drizzle:Taking in count all the above we've came up with potential solution for the config file to unify
driveranddialectfields into one, which will consist ofdialect:driverand changepgdialect topostgresql:That would let us keep
dbCredentialstyped and will end up in a list ofdatabaseparams beBig questions:
push,pullandstudiocommands, since those only requiredialect.postgres:neonfor example, he might be able to connect to neon database not through@neondatabase/serverlessdriver, but throughpgorpostgresdrivers. Should we check runtime deps strictly for@neondatabase/serverlessand fail if it's not present or also try bothpgandpostgresFor the first one we might let them just provide
database: "dialect"without:driverpart?For the second one we lean heavily towards trying all possible drivers and connect through the first one available as long as all of them compatible
UPD(27 may 2024)
better-sqliteandlibsqlcompatibility - we need to automatically prefix files url withfile:forlibsqlif missing and make sure to trim it forbetter-sqliteforneonandvercelserverless drivers we need to check for-poolerin connection strings and automatically create aPoolinstead of aClientto not throw errors@neondatabase/serverlessusecreatePool@vercel/postgresusecreatePool(waiting for Vercel to resolve-poolerissue, which prevents pool creation with a non-pooler connection)All reactions