[FeatureRequest] generate defineTable ts code with mammoth-cli
Opened this issue · 4 comments
xialvjun commented
So we can include it in our build process.
martijndeh commented
And based on what should the defineTable() calls be generated? Your database schema or your migrations or what are you thinking?
xialvjun commented
> 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.
martijndeh commented
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?
xialvjun commented
There are just 2 development mode:
- Manage the database schema with other things. Use
mammoth generate
and integrate with CI to help development; - Manage the database schema with
mammoth migrate
. I think we can havemammoth test -c postgres://localhost/my_db
in CI to check if anyone modify database schema.