bikeshedder / tusker

PostgreSQL migration management tool
The Unlicense
208 stars 17 forks source link

Feature Request: Allow comma separated glob patterns in config.schema.filename #24

Closed whalespine closed 1 year ago

whalespine commented 1 year ago

Only thing missing from tusker for my use case is the ability to specify several separate patterns in the schema.filename configuration.

Config file sample:

[schema]
filename = "schema/*.sql,procs/**/*.sql"

Here's the diff. I can submit a PR if you want to give me permission.

index 98f695e..0251f37 100644
--- a/tusker/__init__.py
+++ b/tusker/__init__.py
@@ -109,9 +109,10 @@ class Tusker:
         with self.createdb('schema') as schema_engine:
             with schema_engine.begin() as schema_cursor:
                 self.log('Creating original schema...')
-                for filename in sorted(glob(self.config.schema.filename, recursive=True)):
-                    self.log('- {}'.format(filename))
-                    execute_sql_file(schema_cursor, filename)
+                for pattern in self.config.schema.filename.split(","):
+                    for filename in sorted(glob(pattern, recursive=True)):
+                        self.log('- {}'.format(filename))
+                        execute_sql_file(schema_cursor, filename)
             yield schema_engine

     @contextmanager
whalespine commented 1 year ago

Figured out how to do a PR from a fork. See https://github.com/bikeshedder/tusker/pull/25

bikeshedder commented 1 year ago

This was implemented in #26.