Ff00ff/mammoth

[FeatureRequest] generate defineTable ts code with mammoth-cli

Opened this issue · 4 comments

So we can include it in our build process.

And based on what should the defineTable() calls be generated? Your database schema or your migrations or what are you thinking?

> mammoth generate -c postgres://localhost/my_db -o src/tables.ts
# Now my_db should have a table 'migration' and with a migration record. And comes out two files 'migrations/001.sql' and 'src/tables.ts'

Well, in this use case, we don't need to include it in ci.

Right, so you want to generate all your defineTable() calls based your existing schema.

Question: when you introduce a new table, how do you do that? Do you not write your own defineTable call? Or do you only want to generate the defineTable calls once so you can more easily start using Mammoth?

There are just 2 development mode:

  1. Manage the database schema with other things. Use mammoth generate and integrate with CI to help development;
  2. Manage the database schema with mammoth migrate. I think we can have mammoth test -c postgres://localhost/my_db in CI to check if anyone modify database schema.