mirror of
https://github.com/yandex/pgmigrate.git
synced 2024-10-05 16:17:14 +03:00
Allow using subdirs in migrations folder
This commit is contained in:
parent
37933c90b6
commit
1305fd109a
2
AUTHORS
2
AUTHORS
@ -1,4 +1,4 @@
|
||||
(C) YANDEX LLC, 2016-2017
|
||||
(C) YANDEX LLC, 2016-2018
|
||||
|
||||
People that contributed to it:
|
||||
|
||||
|
14
pgmigrate.py
14
pgmigrate.py
@ -214,6 +214,15 @@ Config = namedtuple('Config', ('target', 'baseline', 'cursor', 'dryrun',
|
||||
CONFIG_IGNORE = ['cursor', 'conn_instance', 'terminator_instance']
|
||||
|
||||
|
||||
def _get_files_from_dir(path):
|
||||
"""
|
||||
Get all files in all subdirs in path
|
||||
"""
|
||||
for root, _, files in os.walk(path):
|
||||
for fname in files:
|
||||
yield fname, os.path.join(root, fname)
|
||||
|
||||
|
||||
def _get_migrations_info_from_dir(base_dir):
|
||||
"""
|
||||
Get all migrations from base dir
|
||||
@ -224,10 +233,7 @@ def _get_migrations_info_from_dir(base_dir):
|
||||
raise ConfigurationError(
|
||||
'Migrations dir not found (expected to be {path})'.format(
|
||||
path=path))
|
||||
for fname in os.listdir(path):
|
||||
file_path = os.path.join(path, fname)
|
||||
if not os.path.isfile(file_path):
|
||||
continue
|
||||
for fname, file_path in _get_files_from_dir(path):
|
||||
match = MIGRATION_FILE_RE.match(fname)
|
||||
if match is None:
|
||||
LOG.warning(
|
||||
|
4
setup.py
4
setup.py
@ -4,8 +4,8 @@ setup.py for pgmigrate
|
||||
"""
|
||||
# encoding: utf-8
|
||||
#
|
||||
# Copyright (c) 2016-2017 Yandex LLC <https://github.com/yandex>
|
||||
# Copyright (c) 2016-2017 Other contributors as noted in the AUTHORS file.
|
||||
# Copyright (c) 2016-2018 Yandex LLC <https://github.com/yandex>
|
||||
# Copyright (c) 2016-2018 Other contributors as noted in the AUTHORS file.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and its
|
||||
# documentation for any purpose, without fee, and without a written
|
||||
|
Loading…
Reference in New Issue
Block a user