mirror of
https://github.com/yandex/pgmigrate.git
synced 2024-09-17 15:17:18 +03:00
Move to const
This commit is contained in:
parent
753d964d54
commit
788d49d05e
@ -1,10 +1,11 @@
|
||||
from behave import then
|
||||
from pgmigrate import MalformedMigration, _get_migrations_info_from_dir
|
||||
from pgmigrate import DEFAULT_MIGRATION_RE
|
||||
|
||||
|
||||
@then('versions conflict with version={version}')
|
||||
def step_impl(context, version):
|
||||
pattern = r'V(?P<version>\d+)__(?P<description>.+)\.sql$'
|
||||
pattern = DEFAULT_MIGRATION_RE
|
||||
try:
|
||||
_get_migrations_info_from_dir(context.migr_dir, pattern)
|
||||
except MalformedMigration as e:
|
||||
|
@ -1,5 +1,5 @@
|
||||
from behave import then
|
||||
from pgmigrate import _get_info
|
||||
from pgmigrate import _get_info, DEFAULT_MIGRATION_RE
|
||||
|
||||
|
||||
@then("migration info contains forced baseline={baseline}")
|
||||
@ -7,7 +7,7 @@ def step_impl(context, baseline):
|
||||
context.cursor = context.conn.cursor()
|
||||
context.base_dir = context.migr_dir
|
||||
context.target = 1
|
||||
context.pattern = r'V(?P<version>\d+)__(?P<description>.+)\.sql$'
|
||||
context.pattern = DEFAULT_MIGRATION_RE
|
||||
info = _get_info(context, baseline)
|
||||
assert list(info.values())[0]['version'] == int(baseline)
|
||||
assert list(info.values())[0]['description'] == 'Forced baseline'
|
||||
|
@ -1,5 +1,5 @@
|
||||
from behave import then
|
||||
from pgmigrate import _get_info
|
||||
from pgmigrate import _get_info, DEFAULT_MIGRATION_RE
|
||||
|
||||
|
||||
@then("migration info contains single migration")
|
||||
@ -7,7 +7,7 @@ def step_impl(context):
|
||||
context.cursor = context.conn.cursor()
|
||||
context.base_dir = context.migr_dir
|
||||
context.target = 1
|
||||
context.pattern = r'V(?P<version>\d+)__(?P<description>.+)\.sql$'
|
||||
context.pattern = DEFAULT_MIGRATION_RE
|
||||
info = _get_info(context, 0)
|
||||
assert list(info.values())[0]['version'] == 1
|
||||
assert list(info.values())[0]['description'] == 'Single migration'
|
||||
|
@ -1,9 +1,9 @@
|
||||
from behave import then
|
||||
from pgmigrate import _get_migrations_info_from_dir
|
||||
from pgmigrate import _get_migrations_info_from_dir, DEFAULT_MIGRATION_RE
|
||||
|
||||
|
||||
@then('migration list is empty')
|
||||
def step_impl(context):
|
||||
pattern = r'V(?P<version>\d+)__(?P<description>.+)\.sql$'
|
||||
pattern = DEFAULT_MIGRATION_RE
|
||||
assert len(_get_migrations_info_from_dir(context.migr_dir,
|
||||
pattern).keys()) == 0
|
||||
|
@ -1,10 +1,10 @@
|
||||
from behave import then
|
||||
from pgmigrate import _get_migrations_info_from_dir
|
||||
from pgmigrate import _get_migrations_info_from_dir, DEFAULT_MIGRATION_RE
|
||||
|
||||
|
||||
@then('migration list equals single transactional migration')
|
||||
def step_impl(context):
|
||||
pattern = r'V(?P<version>\d+)__(?P<description>.+)\.sql$'
|
||||
pattern = DEFAULT_MIGRATION_RE
|
||||
assert len(_get_migrations_info_from_dir(context.migr_dir,
|
||||
pattern).keys()) == 1
|
||||
migration = list(_get_migrations_info_from_dir(context.migr_dir,
|
||||
|
11
pgmigrate.py
11
pgmigrate.py
@ -698,10 +698,11 @@ COMMANDS = {
|
||||
'migrate': migrate,
|
||||
}
|
||||
|
||||
DEFAULT_MIGRATION_RE = r'V(?P<version>\d+)__(?P<description>.+)\.sql$'
|
||||
|
||||
CONFIG_DEFAULTS = Config(target=None, baseline=0, cursor=None, dryrun=False,
|
||||
callbacks='', base_dir='',
|
||||
pattern=r'V(?P<version>\d+)__'
|
||||
r'(?P<description>.+)\.sql$',
|
||||
pattern=DEFAULT_MIGRATION_RE,
|
||||
user=None, session=['SET lock_timeout = 0'],
|
||||
conn='dbname=postgres user=postgres '
|
||||
'connect_timeout=1',
|
||||
@ -777,11 +778,9 @@ def _main():
|
||||
help='Migrations base dir')
|
||||
parser.add_argument('-p', '--pattern',
|
||||
type=str,
|
||||
default=r'V(?P<version>\d+)__'
|
||||
r'(?P<description>.+)\.sql$',
|
||||
default=DEFAULT_MIGRATION_RE,
|
||||
help=r'Migrations filename pattern, '
|
||||
r'default value is '
|
||||
r'V(?P<version>\d+)__(?P<description>.+)\.sql$')
|
||||
r'default value is ' + DEFAULT_MIGRATION_RE)
|
||||
parser.add_argument('-u', '--user',
|
||||
type=str,
|
||||
help='Override database user in migration info')
|
||||
|
Loading…
Reference in New Issue
Block a user