1
1
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:
secwall 2018-04-03 06:03:44 +03:00
parent 37933c90b6
commit 1305fd109a
4 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,4 @@
(C) YANDEX LLC, 2016-2017
(C) YANDEX LLC, 2016-2018
People that contributed to it:

View File

@ -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(

View File

@ -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

View File

@ -60,5 +60,5 @@ deps = pylint
[flake8]
copyright-check = True
copyright-regexp = Copyright\s+(\(C\)\s+)?(\d{4}-)?2016-2017\s+%(author)s
copyright-regexp = Copyright\s+(\(C\)\s+)?(\d{4}-)?2016-2018\s+%(author)s
copyright-author = Yandex LLC