Ff00ff / mammoth-cli

MIT License
22 stars 1 forks source link

Define tables via codegen #2

Open olso opened 3 years ago

olso commented 3 years ago

Hi, saw you on Twitter

https://github.com/SweetIQ/schemats but for defineTables would be nice

martijndeh commented 3 years ago

Hi! Great to hear. Where on Twitter was that?

There is something coming to quickly get you started if you have an existing database schema already. Basically to generate your define table calls from an SQL dump. I was thinking of a command named mammoth setup. What do you think?

The goal will never be to continuously generate define table calls while you update your sql schema—but only once as a sort of one-time setup. Mammoth's goal is to create a type safe query builder as close to SQL as possible without a build step. We believe this will give the best developer experience.

olso commented 3 years ago

https://twitter.com/JavaScriptDaily/status/1325212187477090311 @martijndeh 100 likes already, nice 👏

Our current setup is db-migrate knex schemats

As you can imagine the flow is kind of meh

  1. Write db-migrate migration
  2. Run schemats to generate new db types
  3. Fix knex calls due to type errors and pray that something didn't fuck up because it's hard to type knex completely, and pg is just one of the adapters

mammoth setup is nice, but also having the ability to run it multiple types would be appriecated, because rewrite to mammoth in our cause would happen over time, not in one PR

martijndeh commented 3 years ago

Right, invoking it multiple times for the sake of gradually adopting Mammoth sounds ok. There is a similar request at https://github.com/Ff00ff/mammoth/issues/191.