K
Kyselyā€¢2w ago
mike

How to define multiple configs in a NX monorepo?

Hi, we have multiple applications in a NX monorepo and I need separate configs for migrations and seeders. How would you recommend to do it? When using kysely init it creates the kysely.config.ts in the root ./config. Should I use conditional app selection by env variables?
11 Replies
Igal (mobile)
Igal (mobile)ā€¢2w ago
Hey šŸ‘‹ The configuration supports envrionment-specific overrides.
mike
mikeOPā€¢2w ago
I finally did it this way (switching different settings by env variable passed before the script) as follows. Is there a way how to change naming convention from timestamp_name.ts to timestamp-name.ts...?
KYSELY_DATA_SOURCE=app1 npx kysely seed make test
KYSELY_DATA_SOURCE=app1 npx kysely seed make test
Igal (mobile)
Igal (mobile)ā€¢2w ago
not what I meant
mike
mikeOPā€¢2w ago
so can you please give me a hint? a link maybe?
Igal
Igalā€¢2w ago
GitHub
GitHub - unjs/c12: āš™ļø Smart Configuration Loader
āš™ļø Smart Configuration Loader. Contribute to unjs/c12 development by creating an account on GitHub.
mike
mikeOPā€¢2w ago
thanx. I'll take a look One more thing - I successfully run the seeders as follows but I it does not save the seeder in any log table as it is happening in migrations. Once the seeder has been successfully executed it should not been executed again or do I miss anything?
kysely seed run
ā— Starting seed run
āœ” Seed successful
ā„¹ Ran 1 seed:
[āœ“] 1730819003844_seed-postal-codes
kysely seed run
ā— Starting seed run
āœ” Seed successful
ā„¹ Ran 1 seed:
[āœ“] 1730819003844_seed-postal-codes
Igal (mobile)
Igal (mobile)ā€¢2w ago
yeah that's how seeds work in knex iirc e.g. your seed file might be some non-deterministic code. there should not be anything stopping you from running it again, at least by default
mike
mikeOPā€¢2w ago
you mean to use .onConflict((cb) => cb.doNothing())...? šŸ¤·ā€ā™‚ļø or update of course
Igal (mobile)
Igal (mobile)ā€¢2w ago
e.g. you're using faker to generate 100 users
mike
mikeOPā€¢2w ago
I am using it to init core data such as postal codes, countries, currencies, etc. to push necessary data to make the application up-and-running. So I seed these data but later we want to add one new country and remove one existing country. In such a case I should delete one of the existing countries (if it exists with a delete where clause ) and then seed with onConflict clause everything again? Is this really the "right" pattern?
Igal
Igalā€¢2w ago
what database are you using?
Want results from more Discord servers?
Add your server