Repository: rucio/rucio

Issue:
Subscriptions columns for filter and replication_rules need to be extended
Motivation
----------
Subscriptions columns for filter and replication_rules need to be extended
```
class Subscription(BASE, ModelBase, Versioned):
    """Represents a subscription"""
    __tablename__ = 'subscriptions'
    id = Column(GUID(), default=utils.generate_uuid)
    name = Column(String(64))
    filter = Column(String(2048))
    replication_rules = Column(String(1024))
```







Discussion:

Resolving patch:
diff --git a/lib/rucio/alembicrevision.py b/lib/rucio/alembicrevision.py
--- a/lib/rucio/alembicrevision.py
+++ b/lib/rucio/alembicrevision.py
@@ -17,5 +17,6 @@
 # - Benedikt Ziemons <benedikt.ziemons@cern.ch>, 2020
 # - Martin Barisits <martin.barisits@cern.ch>, 2020
 # - Matt Snyder <msnyder@bnl.gov>, 2021
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2021
 
-ALEMBIC_REVISION = 'f85a2962b021'  # the current alembic head revision
+ALEMBIC_REVISION = 'e138c364ebd0'  # the current alembic head revision
diff --git a/lib/rucio/db/sqla/migrate_repo/versions/e138c364ebd0_extending_columns_for_filter_and_.py b/lib/rucio/db/sqla/migrate_repo/versions/e138c364ebd0_extending_columns_for_filter_and_.py
new file mode 100644
--- /dev/null
+++ b/lib/rucio/db/sqla/migrate_repo/versions/e138c364ebd0_extending_columns_for_filter_and_.py
@@ -0,0 +1,54 @@
+# Copyright 2013-2021 CERN
+#
+# 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:
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2021
+
+''' Extending columns for filter and replication_rules in subscriptions '''
+
+import sqlalchemy as sa
+
+from alembic import context
+from alembic.op import alter_column
+
+
+# Alembic revision identifiers
+revision = 'e138c364ebd0'
+down_revision = 'f85a2962b021'
+
+
+def upgrade():
+    '''
+    Upgrade the database to this revision
+    '''
+
+    schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
+    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
+        alter_column('subscriptions', 'filter', existing_type=sa.String(2048), type_=sa.String(4000), schema=schema)
+        alter_column('subscriptions', 'replication_rules', existing_type=sa.String(1024), type_=sa.String(4000), schema=schema)
+        alter_column('subscriptions_history', 'filter', existing_type=sa.String(2048), type_=sa.String(4000), schema=schema)
+        alter_column('subscriptions_history', 'replication_rules', existing_type=sa.String(1024), type_=sa.String(4000), schema=schema)
+
+
+def downgrade():
+    '''
+    Downgrade the database to the previous revision
+    '''
+
+    schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
+    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
+        alter_column('subscriptions', 'filter', existing_type=sa.String(4000), type_=sa.String(2048), schema=schema)
+        alter_column('subscriptions', 'replication_rules', existing_type=sa.String(4000), type_=sa.String(1024), schema=schema)
+        alter_column('subscriptions_history', 'filter', existing_type=sa.String(4000), type_=sa.String(2048), schema=schema)
+        alter_column('subscriptions_history', 'replication_rules', existing_type=sa.String(4000), type_=sa.String(1024), schema=schema)
diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py
--- a/lib/rucio/db/sqla/models.py
+++ b/lib/rucio/db/sqla/models.py
@@ -18,7 +18,7 @@
 # - Joaquín Bogado <jbogado@linti.unlp.edu.ar>, 2015-2019
 # - Wen Guan <wen.guan@cern.ch>, 2015
 # - Martin Barisits <martin.barisits@cern.ch>, 2015-2020
-# - Cedric Serfon <cedric.serfon@cern.ch>, 2016-2020
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2016-2021
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2017-2020
 # - asket <asket.agarwal96@gmail.com>, 2018
 # - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2019
@@ -1235,8 +1235,8 @@ class Subscription(BASE, ModelBase, Versioned):
     __tablename__ = 'subscriptions'
     id = Column(GUID(), default=utils.generate_uuid)
     name = Column(String(64))
-    filter = Column(String(2048))
-    replication_rules = Column(String(1024))
+    filter = Column(String(4000))
+    replication_rules = Column(String(4000))
     policyid = Column(SmallInteger, server_default='0')
     state = Column(Enum(SubscriptionState, name='SUBSCRIPTIONS_STATE_CHK',
                         values_callable=lambda obj: [e.value for e in obj]),


Test patch: