jschaf / pggen

Generate type-safe Go for any Postgres query. If Postgres can run the query, pggen can generate code for it.
MIT License
287 stars 26 forks source link

Add schema-glob flag #5

Closed jschaf closed 3 years ago

jschaf commented 3 years ago

Schema glob allows uses cases like pointing to a directory of migrations or schema files. Implementing schema globbing is more difficult than query globs because the order or running schema files is important. For example, assuming the following directory structure:

one.sql
migrations/
   - 01_create_tables.sql
   - 02_create_roles.sql
   - 03_custom_script.sh
two.sh

Then, the command:

pggen gen go --schema-file 'one.sql' --schema-glob 'migrations/*.sql' --schema-file 'two.sh'

should populate the Docker entrypoint directory with:

01_one.sql
02_01_create_tables.sql
03_02_create_roles.sql
04_03_custom_script.sh
jschaf commented 3 years ago

Fixed in 55216fef78381d047e4b7587b8133eb5ba6de932.

I simplified by removing --schema-file so it's just --schema-glob.