# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors:
# - Martin Barisits <martin.barisits@cern.ch>, 2019
#
# Topic: Replicas table PK definition is in wrong order
# Revision ID: 3345511706b8
# Revises: 9eb936a81eb1
# Creation Date: 2019-01-30 14:20:35.058889

from alembic.op import (create_primary_key, drop_constraint)

from alembic import context


# revision identifiers used by alembic
revision = '3345511706b8'       # pylint: disable=invalid-name
down_revision = 'bf3baa1c1474'  # pylint: disable=invalid-name


def upgrade():
    '''
    Upgrade the database to this revision
    '''
    if context.get_context().dialect.name != 'sqlite':
        drop_constraint('REPLICAS_PK', 'replicas')
        create_primary_key('REPLICAS_PK', 'replicas', ['scope', 'name', 'rse_id'])


def downgrade():
    '''
    Downgrade the database to the previous revision
    '''
    if context.get_context().dialect.name != 'sqlite':
        drop_constraint('REPLICAS_PK', 'replicas')
        create_primary_key('REPLICAS_PK', 'replicas', ['rse_id', 'scope', 'name'])

lib/rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py
# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Authors:
# - Martin Barisits <martin.barisits@cern.ch>, 2019
#
# Topic: Replicas table PK definition is in wrong order
# Revision ID: 3345511706b8
# Revises: 9eb936a81eb1
# Creation Date: 2019-01-30 14:20:35.058889

from alembic.op import (create_primary_key, drop_constraint)

from alembic import context


# revision identifiers used by alembic
revision = '3345511706b8'       # pylint: disable=invalid-name
down_revision = '01eaf73ab656'  # pylint: disable=invalid-name


def upgrade():
    '''
    Upgrade the database to this revision
    '''
    if context.get_context().dialect.name != 'sqlite':
        drop_constraint('REPLICAS_PK', 'replicas')
        create_primary_key('REPLICAS_PK', 'replicas', ['scope', 'name', 'rse_id'])


def downgrade():
    '''
    Downgrade the database to the previous revision
    '''
    if context.get_context().dialect.name != 'sqlite':
        drop_constraint('REPLICAS_PK', 'replicas')
        create_primary_key('REPLICAS_PK', 'replicas', ['rse_id', 'scope', 'name'])

lib/rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py
diff --git a/lib/rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py b/lib/rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py
index 286119c25f..eb2eb917e6 100644
--- a/lib/rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py
+++ b/lib/rucio/db/sqla/migrate_repo/versions/3345511706b8_replicas_table_pk_definition_is_in_.py
@@ -27,7 +27,7 @@
 
 # revision identifiers used by alembic
 revision = '3345511706b8'       # pylint: disable=invalid-name
-down_revision = 'bf3baa1c1474'  # pylint: disable=invalid-name
+down_revision = '01eaf73ab656'  # pylint: disable=invalid-name
 
 
 def upgrade():
diff --git a/tools/pip-requires b/tools/pip-requires
index 9a2cf2cd27..7dcd010ec4 100644
--- a/tools/pip-requires
+++ b/tools/pip-requires
@@ -1,43 +1,43 @@
 # All dependencies needed to run rucio should be defined here
 
-SQLAlchemy==1.2.7                                 # db backend
-alembic==0.9.9                                    # Lightweight database migration tool for SQLAlchemy
+SQLAlchemy==1.2.16                                # db backend
+alembic==1.0.6                                    # Lightweight database migration tool for SQLAlchemy
 Mako==1.0.7                                       # Templating language - Dependency of alembic
 python-editor==1.0.3                              # Programmatically open an editor, capture the result
 flup==1.0.3                                       # Needed to deploy web.py in lighthttpd
 web.py==0.39                                      # Python web framework
 python-memcached==1.59                            # Quick and small memcached client for Python
 jsonschema==2.6.0                                 # JSON Schema
-python-dateutil==2.7.2                            # Extensions to the standard datetime module
+python-dateutil==2.7.5                            # Extensions to the standard datetime module
 pysftp==0.2.9                                     # forces installation of paramikoi and pycrypto
 pycrypto==2.6.1                                   # Cryptographic modules
-s3cmd==2.0.1                                      # Package built from http://s3tools.org/download
-stomp.py==4.1.20                                  # ActiveMQ Messaging Protocol
+s3cmd==2.0.2                                      # Package built from http://s3tools.org/download
+stomp.py==4.1.21                                  # ActiveMQ Messaging Protocol
 pystatsd==0.1.10; python_version == '2.7'         # Needed to log into graphite with more than 1 Hz
 pygeoip==0.3.2                                    # GeoIP API
-geoip2==2.8.0                                     # GeoIP2 API (for IPv6 support)
+geoip2==2.9.0                                     # GeoIP2 API (for IPv6 support)
 ipaddress==1.0.22                                 # IPv4/IPv6 manipulation library - Dependency of geoip2
-maxminddb==1.3.0                                  # extension for reading the MaxMind DB format - Dependency of geoip2
+maxminddb==1.4.1                                  # extension for reading the MaxMind DB format - Dependency of geoip2
 cffi==1.11.5                                      # Foreign Function Interface for Python calling C code
-pycparser==2.18                                   # C parser in Python - Dependency of cffi
+pycparser==2.19                                   # C parser in Python - Dependency of cffi
 gcloud==0.18.3                                    # API Client library for Google Cloud
-googleapis-common-protos==1.5.3                   # Common protobufs used in Google APIs - Dependency of gcloud
-httplib2==0.11.3                                  # A comprehensive HTTP client library
-pyOpenSSL==18.0.0                                 # Python wrapper module around the OpenSSL library - Dependency of MyProxyClient
-cryptography==2.3.1                               # Cryptographic recipes and primitives - Dependency of pyOpenSSL
-oauth2client==4.1.2                               # OAuth 2.0 client library
-protobuf==3.5.2.post1                             # Protocol Buffers - Dependency of gcloud
-grpcio==1.11.0                                    # Package for gRPC Python.
+googleapis-common-protos==1.5.6                   # Common protobufs used in Google APIs - Dependency of gcloud
+httplib2==0.12.0                                  # A comprehensive HTTP client library
+pyOpenSSL==19.0.0                                 # Python wrapper module around the OpenSSL library - Dependency of MyProxyClient
+cryptography==2.4.2                               # Cryptographic recipes and primitives - Dependency of pyOpenSSL
+oauth2client==4.1.3                               # OAuth 2.0 client library
+protobuf==3.6.1                                   # Protocol Buffers - Dependency of gcloud
+grpcio==1.18.0                                    # Package for gRPC Python.
 enum34==1.1.6                                     # Python 3.4 Enum backported - Dependency of grpcio
-pyasn1==0.4.2                                     # Dependency of oauth2client
-pyasn1-modules==0.2.1                             # A collection of ASN.1-based protocols modules - Dependency of oauth2client
-rsa==3.4.2                                        # Pure-Python RSA implementation
+pyasn1==0.4.5                                     # Dependency of oauth2client
+pyasn1-modules==0.2.3                             # A collection of ASN.1-based protocols modules - Dependency of oauth2client
+rsa==4.0                                          # Pure-Python RSA implementation
 retrying==1.3.3                                   # general-purpose retrying library to simplify the task of adding retry behavior to just about anything
 functools32==3.2.3.post2; python_version == '2.7'    # explicitly needed on CC7
-redis==2.10.6                                     # Python client for Redis key-value store
+redis==3.0.1                                      # Python client for Redis key-value store
 numpy==1.14.2                                     # Numpy for forecasting T3C
 paramiko==2.4.2                                   # SSH2 protocol library
-Flask==0.12.4                                     # Python web framework
-idna==2.6                                         # Internationalized Domain Names in Applications (IDNA) - Dependency of requests
+Flask==1.0.2                                      # Python web framework
+idna==2.8                                         # Internationalized Domain Names in Applications (IDNA) - Dependency of requests
 fts3-rest-API==3.7.1                              # FTS rest API
-MyProxyClient==2.0.1                              # myproxy client bindings
+MyProxyClient==2.1.0                              # myproxy client bindings
diff --git a/tools/pip-requires-test b/tools/pip-requires-test
index 18f8e91f7d..687c659cdd 100755
--- a/tools/pip-requires-test
+++ b/tools/pip-requires-test
@@ -1,26 +1,26 @@
 # All dependencies needed to develop/test rucio should be defined here
 
 pinocchio==0.4.2            # Extensions for the 'nose' unit testing framework
-Paste==2.0.3                # Utilities for web development in pyton
+Paste==3.0.6                # Utilities for web development in pyton
 unittest2==1.1.0            # backport of unittest lib in python 2.7
-coverage==4.4.2             # Nose module for test coverage
-Sphinx==1.6.5               # required to build documentation
-sphinx-rtd-theme==0.2.4     # Read the Docs theme for Sphinx
+coverage==4.5.2             # Nose module for test coverage
+Sphinx==1.8.3               # required to build documentation
+sphinx-rtd-theme==0.4.2     # Read the Docs theme for Sphinx
 Jinja2==2.10                # template engine
-sphinxcontrib-httpdomain==1.6.0 # Provides a Sphinx domain for describing RESTful HTTP APIs
+sphinxcontrib-httpdomain==1.7.0 # Provides a Sphinx domain for describing RESTful HTTP APIs
 stub==0.2.1; python_version == '2.7' # Temporarily modify callable behaviour and object attributes
 Pygments==2.2.0             # Python Syntax highlighter
 docutils==0.14              # Needed for sphinx
-pyflakes==1.6.0             # Passive checker of Python programs
+pyflakes==2.0.0             # Passive checker of Python programs
 flake8==3.5.0               # Wrapper around PyFlakes&pep8
-pylint==1.7.4; python_version >= '2.7' # static code analysis. Last release compatible with python 2.6
-virtualenv==15.1.0          # Virtual Python Environment builder
-tox==2.9.1                  # Automate and standardize testing in Python
-pytest==3.2.5
-pytest-xdist==1.20.1        # py.test xdist plugin for distributed testing and loop-on-failing modes
+pylint==1.9.4; python_version >= '2.7' # static code analysis. 1.9.4 last 2.7 compatible release
+virtualenv==16.2.0          # Virtual Python Environment builder
+tox==3.7.0                  # Automate and standardize testing in Python
+pytest==4.1.1
+pytest-xdist==1.26.0        # py.test xdist plugin for distributed testing and loop-on-failing modes
 xmltodict==0.11.0           # Makes working with XML feel like you are working with JSON
-pytz==2017.3                # World timezone definitions, modern and historical
-Babel==2.5.1                # Internationalization utilities - Dependency of sphinx
-subprocess32==3.2.7; python_version <= '3.0' # A backport of the subprocess module from Python 3.2/3.3 for use on 2.x.
+pytz==2018.9                # World timezone definitions, modern and historical
+Babel==2.6.0                # Internationalization utilities - Dependency of sphinx
+subprocess32==3.5.3; python_version <= '3.0' # A backport of the subprocess module from Python 3.2/3.3 for use on 2.x.
 pycodestyle==2.3.1          # New package replacing pep8
 mock==2.0.0                 # Mock package needed for readthedocs build for mocking pycurls

Upgrade of dependencies for 1.19.0
Modification
------------
# pip-requires
SQLAlchemy 1.2.7 --> 1.2.16
alembic 0.9.9 --> 1.0.6
python-dateutil 2.7.2 --> 2.7.5
s3cmd 2.0.1 --> 2.0.2
stomp.py 4.1.20 --> 4.1.21
dnspython 1.15.0 --> 1.16.0
geoip2 2.8.0 --> 2.9.0
maxminddb 1.3.0 --> 1.4.1
pycparser 2.18 --> 2.19
googleapis-common-protos 1.5.3 --> 1.5.6
httplib2 0.11.3 --> 0.12.0
pyOpenSSL 18.0.0 --> 19.0.0
cryptography 2.3.1 --> 2.4.2
oauth2client 4.1.2 --> 4.1.3
protobuf 3.5.2.post1 --> 3.6.1
grpcio 1.11.0 --> 1.18.0
pyasn1 0.4.2 --> 0.4.5
pyasn1-modules 0.2.1 --> 0.2.3
rsa 3.4.2 --> 4.0
redis 2.10.6 --> 3.0.1
numpy 1.14.2 --> 1.16.0
paramiko 2.4.1 --> 2.4.2
Flask 0.12.4 --> 1.0.2
idna 2.6 --> 2.8
MyProxyClient 2.0.1 --> 2.1.0

# pip-requires-test
Paste 2.0.3 --> 3.0.6
coverage 4.4.2 --> 4.5.2
Sphinx 1.6.5 --> 1.8.3
sphinx-rtd-theme 0.2.4 --> 0.4.2
sphinxcontrib-httpdomain 1.6.0 --> 1.7.0
Pygments 2.2.0 --> 2.3.1
pyflakes 1.6.0 --> 2.0.0
flake8 3.5.0 --> 3.6.0
pylint 1.7.4 --> 2.2.2
virtualenv 15.1.0 --> 16.2.0
tox 2.9.1 --> 3.7.0
pytest 3.2.5 --> 4.1.1
pytest-xdist 1.20.1 --> 1.26.0
pytz 2017.3 --> 2018.9
Babel 2.5.1 --> 2.6.0
subprocess32 3.2.7 --> 3.5.3
pycodestyle 2.3.1 --> 2.4.0
