K
Kyselyβ€’14mo ago
ohmi

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:
Hey πŸ‘‹ type file & kysely instance per database is what I would go for....
Jump to solution
5 Replies
Solution
Igal
Igalβ€’14mo ago
Hey πŸ‘‹ type file & kysely instance per database is what I would go for.
ohmi
ohmiβ€’14mo ago
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?
Igal
Igalβ€’14mo ago
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).
ohmi
ohmiβ€’14mo ago
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
Igal
Igalβ€’14mo ago
it's all @koskimas , I'm just tagging along for the ride 🫢🏻
Want results from more Discord servers?
Add your server
More Posts