kysely-codegen for multiple databases

Oohmi5/19/2023
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
IIgal5/19/2023
Hey πŸ‘‹

type file & kysely instance per database is what I would go for.
Oohmi5/19/2023
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
Oohmi5/19/2023
or is this potential a common use case that can be supported πŸ˜‰
Oohmi5/19/2023
on a different note, are joins on two different databases supported?
IIgal5/19/2023
try submitting an issue @ kysely-codegen
IIgal5/19/2023
multi-database mysql queries depend on mysql2 support.
IIgal5/19/2023
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).
Oohmi5/19/2023
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
Oohmi5/19/2023
but ill get to that when i get there
Oohmi5/19/2023
side note, easily the most enjoyable migration ive ever done my life, big fan of the work you've done πŸ˜„ e
IIgal5/19/2023
it's all @koskimas , I'm just tagging along for the ride 🫢🏻