kysely-codegen for multiple databases
I have two MySQL 'databases' within the same instance. From the documentation, it doesn't look like the codegen has innate support for multiple databases with different schemas?
I could codegen with the two different connection strings with a different
--out-file
, rename the exported interfaces, then manually update index.d.ts
, but I was wondering if there's a better solution?Solution:Jump to solution
Hey π
type file & kysely instance per database is what I would go for....
5 Replies
Solution
Hey π
type file & kysely instance per database is what I would go for.
is there any way to change the name of the auto-generated exported interface? it's "DB" by default i believe.
the workflow im imagining for myself is some script that does the following:
code-gen types for database1, programatically rename "DB" to Database1
code-gen types for database2, programatically rename "DB" to Database2
programmatically add Database1 and Database2 to index.d.ts
or is this potential a common use case that can be supported π
on a different note, are joins on two different databases supported?
try submitting an issue @ kysely-codegen
multi-database mysql queries depend on
mysql2
support.
if it does, might be able to get away with referring to different db's like schema names (which are supported in Kysely because of PostgreSQL).im migrating a fairly large project from knex, so mysql2 should support it, i guess my concern was more if kysely syntax had a way of supporting it
but ill get to that when i get there
side note, easily the most enjoyable migration ive ever done my life, big fan of the work you've done π e
it's all @koskimas , I'm just tagging along for the ride π«Άπ»