mammoth-cli icon indicating copy to clipboard operation
mammoth-cli copied to clipboard

Define tables via codegen

Open olso opened this issue 4 years ago • 3 comments

Hi, saw you on Twitter

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

olso avatar Nov 08 '20 07:11 olso

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.

martijndeh avatar Nov 08 '20 20:11 martijndeh

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

olso avatar Nov 08 '20 21:11 olso

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.

martijndeh avatar Dec 30 '20 14:12 martijndeh