mirror of
https://github.com/yandex/pgmigrate.git
synced 2024-09-17 15:17:18 +03:00
Bump deps versions
This commit is contained in:
parent
8f109e797d
commit
ed897ffb97
@ -13,7 +13,7 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
|
||||
|
||||
ENV PG_MAJOR 10
|
||||
ENV PG_MAJOR 11
|
||||
|
||||
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
|
||||
|
||||
|
@ -40,18 +40,19 @@ def step_impl(context):
|
||||
@given('successful pgmigrate run with our callbacks and "{args}"') # noqa
|
||||
def step_impl(context, args):
|
||||
cbs = ','.join(context.callbacks)
|
||||
context.execute_steps('given successful pgmigrate run with ' +
|
||||
'"%s"' % ('-a ' + cbs + ' ' + args,))
|
||||
context.execute_steps('given successful pgmigrate run with ' + '"%s"' %
|
||||
('-a ' + cbs + ' ' + args, ))
|
||||
|
||||
|
||||
@when('we run pgmigrate with our callbacks and "{args}"') # noqa
|
||||
def step_impl(context, args):
|
||||
cbs = ','.join(context.callbacks)
|
||||
context.execute_steps('when we run pgmigrate with ' +
|
||||
'"%s"' % ('-a ' + cbs + ' ' + args,))
|
||||
context.execute_steps('when we run pgmigrate with ' + '"%s"' %
|
||||
('-a ' + cbs + ' ' + args, ))
|
||||
|
||||
|
||||
@when('we run pgmigrate with dir callbacks and type "{cb_type}" and "{args}"') # noqa
|
||||
@when('we run pgmigrate with dir callbacks and type "{cb_type}" and "{args}"'
|
||||
) # noqa
|
||||
def step_impl(context, cb_type, args):
|
||||
p_args = '-a ' + cb_type + ':' + context.migr_dir + '/callbacks/ ' + args
|
||||
context.execute_steps('when we run pgmigrate with "%s"' % (p_args, ))
|
||||
|
@ -9,12 +9,12 @@ from behave import given, then, when
|
||||
|
||||
|
||||
def run_pgmigrate(migr_dir, args):
|
||||
cmd = ['coverage', 'run', '-p', '--include=pgmigrate.py',
|
||||
'./pgmigrate.py', '-vvv', '-d', migr_dir,
|
||||
'-c', 'dbname=pgmigratetest'] + str(args).split(' ')
|
||||
cmd = [
|
||||
'coverage', 'run', '-p', '--include=pgmigrate.py', './pgmigrate.py',
|
||||
'-vvv', '-d', migr_dir, '-c', 'dbname=pgmigratetest'
|
||||
] + str(args).split(' ')
|
||||
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
try:
|
||||
stdout, stderr = func_timeout(5, p.communicate)
|
||||
@ -23,11 +23,16 @@ def run_pgmigrate(migr_dir, args):
|
||||
stdout, stderr = p.communicate()
|
||||
return p.returncode, str(stdout), str(stderr)
|
||||
|
||||
|
||||
@given('successful pgmigrate run with "{args}"')
|
||||
def step_impl(context, args):
|
||||
if context.migrate_config:
|
||||
with open(os.path.join(context.migr_dir, 'migrations.yml'), 'w') as f:
|
||||
f.write(yaml.dump(context.migrate_config))
|
||||
yaml.safe_dump(context.migrate_config,
|
||||
f,
|
||||
encoding=None,
|
||||
default_flow_style=False,
|
||||
allow_unicode=True)
|
||||
res = run_pgmigrate(context.migr_dir, args)
|
||||
|
||||
if res[0] != 0:
|
||||
@ -40,7 +45,11 @@ def step_impl(context, args):
|
||||
def step_impl(context, args):
|
||||
if context.migrate_config:
|
||||
with open(os.path.join(context.migr_dir, 'migrations.yml'), 'w') as f:
|
||||
f.write(yaml.dump(context.migrate_config))
|
||||
yaml.safe_dump(context.migrate_config,
|
||||
f,
|
||||
encoding=None,
|
||||
default_flow_style=False,
|
||||
allow_unicode=True)
|
||||
res = run_pgmigrate(context.migr_dir, args)
|
||||
|
||||
context.last_migrate_res = {'ret': res[0], 'out': res[1], 'err': res[2]}
|
||||
|
60
pgmigrate.py
60
pgmigrate.py
@ -50,42 +50,36 @@ class MigrateError(RuntimeError):
|
||||
"""
|
||||
Common migration error class
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MalformedStatement(MigrateError):
|
||||
"""
|
||||
Incorrect statement exception
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MalformedMigration(MigrateError):
|
||||
"""
|
||||
Incorrect migration exception
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class MalformedSchema(MigrateError):
|
||||
"""
|
||||
Incorrect schema exception
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ConfigurationError(MigrateError):
|
||||
"""
|
||||
Incorrect config or cmd args exception
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class BaselineError(MigrateError):
|
||||
"""
|
||||
Baseline error class
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ConflictTerminator(threading.Thread):
|
||||
@ -703,8 +697,7 @@ COMMANDS = {
|
||||
'migrate': migrate,
|
||||
}
|
||||
|
||||
CONFIG_DEFAULTS = Config(
|
||||
target=None,
|
||||
CONFIG_DEFAULTS = Config(target=None,
|
||||
baseline=0,
|
||||
cursor=None,
|
||||
dryrun=False,
|
||||
@ -726,7 +719,7 @@ def get_config(base_dir, args=None):
|
||||
path = os.path.join(base_dir, 'migrations.yml')
|
||||
try:
|
||||
with codecs.open(path, encoding='utf-8') as i:
|
||||
base = yaml.load(i.read())
|
||||
base = yaml.safe_load(i)
|
||||
except IOError:
|
||||
LOG.info('Unable to load %s. Using defaults', path)
|
||||
base = {}
|
||||
@ -746,9 +739,8 @@ def get_config(base_dir, args=None):
|
||||
conf = conf._replace(target=int(conf.target))
|
||||
|
||||
if conf.termination_interval and not conf.dryrun:
|
||||
conf = conf._replace(
|
||||
terminator_instance=ConflictTerminator(conf.conn,
|
||||
conf.termination_interval))
|
||||
conf = conf._replace(terminator_instance=ConflictTerminator(
|
||||
conf.conn, conf.termination_interval))
|
||||
conf.terminator_instance.start()
|
||||
|
||||
conf = conf._replace(conn_instance=_create_connection(conf))
|
||||
@ -770,46 +762,50 @@ def _main():
|
||||
"""
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
'cmd', choices=COMMANDS.keys(), type=str, help='Operation')
|
||||
parser.add_argument('cmd',
|
||||
choices=COMMANDS.keys(),
|
||||
type=str,
|
||||
help='Operation')
|
||||
parser.add_argument('-t', '--target', type=str, help='Target version')
|
||||
parser.add_argument(
|
||||
'-c', '--conn', type=str, help='Postgresql connection string')
|
||||
parser.add_argument(
|
||||
'-d', '--base_dir', type=str, default='', help='Migrations base dir')
|
||||
parser.add_argument(
|
||||
'-u',
|
||||
parser.add_argument('-c',
|
||||
'--conn',
|
||||
type=str,
|
||||
help='Postgresql connection string')
|
||||
parser.add_argument('-d',
|
||||
'--base_dir',
|
||||
type=str,
|
||||
default='',
|
||||
help='Migrations base dir')
|
||||
parser.add_argument('-u',
|
||||
'--user',
|
||||
type=str,
|
||||
help='Override database user in migration info')
|
||||
parser.add_argument('-b', '--baseline', type=int, help='Baseline version')
|
||||
parser.add_argument(
|
||||
'-a',
|
||||
parser.add_argument('-a',
|
||||
'--callbacks',
|
||||
type=str,
|
||||
help='Comma-separated list of callbacks '
|
||||
'(type:dir/file)')
|
||||
parser.add_argument(
|
||||
'-s',
|
||||
parser.add_argument('-s',
|
||||
'--session',
|
||||
action='append',
|
||||
help='Session setup (e.g. isolation level)')
|
||||
parser.add_argument(
|
||||
'-n',
|
||||
parser.add_argument('-n',
|
||||
'--dryrun',
|
||||
action='store_true',
|
||||
help='Say "rollback" in the end instead of "commit"')
|
||||
parser.add_argument(
|
||||
'-l',
|
||||
parser.add_argument('-l',
|
||||
'--termination_interval',
|
||||
type=float,
|
||||
help='Inverval for terminating blocking pids')
|
||||
parser.add_argument(
|
||||
'-v', '--verbose', default=0, action='count', help='Be verbose')
|
||||
parser.add_argument('-v',
|
||||
'--verbose',
|
||||
default=0,
|
||||
action='count',
|
||||
help='Be verbose')
|
||||
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(
|
||||
level=(logging.ERROR - 10 * (min(3, args.verbose))),
|
||||
logging.basicConfig(level=(logging.ERROR - 10 * (min(3, args.verbose))),
|
||||
format='%(asctime)s %(levelname)-8s: %(message)s')
|
||||
|
||||
config = get_config(args.base_dir, args)
|
||||
|
@ -5,6 +5,8 @@ set -e
|
||||
chown -R postgres:postgres /dist
|
||||
mkdir -p /var/log/pogsgresql
|
||||
chown postgres:postgres /var/log/pogsgresql
|
||||
sudo -u postgres /usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D /etc/postgresql/10/main -l /var/log/pogsgresql/postgresql-${PG_MAJOR}-main.log start
|
||||
sudo -u postgres /usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D \
|
||||
/etc/postgresql/${PG_MAJOR}/main -l \
|
||||
/var/log/pogsgresql/postgresql-${PG_MAJOR}-main.log start
|
||||
cd /dist
|
||||
sudo -u postgres -i tox -c /dist/tox.ini
|
||||
|
24
setup.py
24
setup.py
@ -30,31 +30,29 @@ try:
|
||||
except ImportError:
|
||||
from distutils import setup
|
||||
|
||||
|
||||
REQUIREMENTS = [
|
||||
'sqlparse >= 0.2.1',
|
||||
'psycopg2 >= 2.6.2',
|
||||
'PyYAML >= 3.12'
|
||||
'sqlparse >= 0.3.0',
|
||||
'psycopg2 >= 2.8.2',
|
||||
'PyYAML >= 5.1',
|
||||
]
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
REQUIREMENTS.append('future >= 0.15.2')
|
||||
REQUIREMENTS.append('future >= 0.17.1')
|
||||
|
||||
setup(
|
||||
name="yandex-pgmigrate",
|
||||
version="1.0.3",
|
||||
description="PostgreSQL migrations made easy",
|
||||
license="PostgreSQL License",
|
||||
url="https://github.com/yandex/pgmigrate/",
|
||||
name='yandex-pgmigrate',
|
||||
version='1.0.3',
|
||||
description='PostgreSQL migrations made easy',
|
||||
license='PostgreSQL License',
|
||||
url='https://github.com/yandex/pgmigrate/',
|
||||
author='Yandex LLC',
|
||||
author_email='opensource@yandex-team.ru',
|
||||
maintainer='Yandex LLC',
|
||||
maintainer_email='opensource@yandex-team.ru',
|
||||
zip_safe=False,
|
||||
platforms=["Linux", "BSD", "MacOS"],
|
||||
platforms=['Linux', 'BSD', 'MacOS'],
|
||||
packages=['.'],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
entry_points={'console_scripts': [
|
||||
'pgmigrate = pgmigrate:_main',
|
||||
]},
|
||||
install_requires=REQUIREMENTS,
|
||||
|
4
tox.ini
4
tox.ini
@ -48,9 +48,9 @@ deps = pylint
|
||||
|
||||
[testenv:yapf]
|
||||
commands = yapf -pd pgmigrate.py
|
||||
deps = yapf==0.22.0
|
||||
deps = yapf==0.27.0
|
||||
|
||||
[flake8]
|
||||
copyright-check = True
|
||||
copyright-regexp = Copyright\s+(\(C\)\s+)?(\d{4}-)?2016-2018\s+%(author)s
|
||||
copyright-regexp = Copyright\s+(\(C\)\s+)?(\d{4}-)?2016-2019\s+%(author)s
|
||||
copyright-author = Yandex LLC
|
||||
|
Loading…
Reference in New Issue
Block a user