K
Kyselyā€¢2mo 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)ā€¢2mo ago
Hey šŸ‘‹ The configuration supports envrionment-specific overrides.
mike
mikeOPā€¢2mo 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)ā€¢2mo ago
not what I meant
mike
mikeOPā€¢2mo ago
so can you please give me a hint? a link maybe?
Igal
Igalā€¢2mo ago
GitHub
GitHub - unjs/c12: āš™ļø Smart Configuration Loader
āš™ļø Smart Configuration Loader. Contribute to unjs/c12 development by creating an account on GitHub.
mike
mikeOPā€¢2mo 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)ā€¢2mo 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ā€¢2mo ago
you mean to use .onConflict((cb) => cb.doNothing())...? šŸ¤·ā€ā™‚ļø or update of course
Igal (mobile)
Igal (mobile)ā€¢2mo ago
e.g. you're using faker to generate 100 users
mike
mikeOPā€¢2mo 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ā€¢2mo ago
what database are you using?
Want results from more Discord servers?
Add your server