diff --git a/lib/rucio/db/sqla/migrate_repo/versions/1a29d6a9504c_add_didtype_chck_to_requests.py b/lib/rucio/db/sqla/migrate_repo/versions/1a29d6a9504c_add_didtype_chck_to_requests.py index 99cecf3a6d..2db1277d83 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/1a29d6a9504c_add_didtype_chck_to_requests.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/1a29d6a9504c_add_didtype_chck_to_requests.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2020 CERN +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016 # - Mario Lassnig , 2019-2020 +# - Benedikt Ziemons , 2021 ''' add didtype_chck to requests ''' @@ -41,7 +42,10 @@ def upgrade(): if context.get_context().dialect.name in ['oracle', 'mysql']: # pylint: disable=no-member add_column('requests', sa.Column('did_type', - sa.Enum(DIDType, name='REQUESTS_DIDTYPE_CHK', values_callable=lambda obj: [e.value for e in obj]), + sa.Enum(DIDType, + name='REQUESTS_DIDTYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj]), default=DIDType.FILE), schema=schema[:-1]) # we don't want checks on the history table, fake the DID type add_column('requests_history', sa.Column('did_type', sa.String(1)), schema=schema[:-1]) diff --git a/lib/rucio/db/sqla/migrate_repo/versions/1d96f484df21_asynchronous_rules_and_rule_approval.py b/lib/rucio/db/sqla/migrate_repo/versions/1d96f484df21_asynchronous_rules_and_rule_approval.py index c6b6a7806e..eb0fb2de6f 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/1d96f484df21_asynchronous_rules_and_rule_approval.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/1d96f484df21_asynchronous_rules_and_rule_approval.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,10 +14,11 @@ # limitations under the License. # # Authors: -# - Vincent Garonne , 2015-2017 +# - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016-2017 # - Mario Lassnig , 2019-2021 # - Robert Illingworth , 2019 +# - Benedikt Ziemons , 2021 ''' asynchronous rules and rule approval ''' @@ -39,19 +41,19 @@ def upgrade(): schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else '' if context.get_context().dialect.name == 'oracle': - add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False)) + add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK', create_constraint=True), default=False)) try_drop_constraint('RULES_STATE_CHK', 'rules') create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O', 'W', 'I')") elif context.get_context().dialect.name == 'postgresql': - add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False), schema=schema[:-1]) + add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK', create_constraint=True), default=False), schema=schema[:-1]) op.execute('ALTER TABLE ' + schema + 'rules DROP CONSTRAINT IF EXISTS "RULES_STATE_CHK", ALTER COLUMN state TYPE CHAR') op.execute("DROP TYPE \"RULES_STATE_CHK\"") op.execute("CREATE TYPE \"RULES_STATE_CHK\" AS ENUM('S', 'R', 'U', 'O', 'W', 'I')") op.execute("ALTER TABLE %srules ALTER COLUMN state TYPE \"RULES_STATE_CHK\" USING state::\"RULES_STATE_CHK\"" % schema) elif context.get_context().dialect.name == 'mysql': - add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False), schema=schema[:-1]) + add_column('rules', sa.Column('ignore_account_limit', sa.Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK', create_constraint=True), default=False), schema=schema[:-1]) op.execute('ALTER TABLE ' + schema + 'rules DROP CHECK RULES_STATE_CHK') # pylint: disable=no-member create_check_constraint('RULES_STATE_CHK', 'rules', "state IN ('S', 'R', 'U', 'O', 'W', 'I')") diff --git a/lib/rucio/db/sqla/migrate_repo/versions/271a46ea6244_add_ignore_availability_column_to_rules.py b/lib/rucio/db/sqla/migrate_repo/versions/271a46ea6244_add_ignore_availability_column_to_rules.py index a86cc932e4..daeb32da00 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/271a46ea6244_add_ignore_availability_column_to_rules.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/271a46ea6244_add_ignore_availability_column_to_rules.py @@ -1,4 +1,5 @@ -# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,9 +14,10 @@ # limitations under the License. # # Authors: -# - Martin Barisits , 2015 -# - Vincent Garonne , 2017 -# - Mario Lassnig , 2019 +# - Vincent Garonne , 2015-2017 +# - Martin Barisits , 2016 +# - Mario Lassnig , 2017-2019 +# - Benedikt Ziemons , 2021 ''' add ignore_availability column to rules ''' @@ -37,7 +39,7 @@ def upgrade(): if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - add_column('rules', sa.Column('ignore_availability', sa.Boolean(name='RULES_IGNORE_AVAILABILITY_CHK'), default=False), schema=schema) + add_column('rules', sa.Column('ignore_availability', sa.Boolean(name='RULES_IGNORE_AVAILABILITY_CHK', create_constraint=True), default=False), schema=schema) def downgrade(): diff --git a/lib/rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py b/lib/rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py index 30f608eb99..5326f0333b 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/3082b8cef557_add_naming_convention_table_and_closed_.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2020 CERN +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ # - Martin Barisits , 2016 # - Mario Lassnig , 2019-2020 # - James Perry , 2020 +# - Benedikt Ziemons , 2021 ''' add convention table and closed_at to dids ''' @@ -50,7 +51,10 @@ def upgrade(): create_table('naming_conventions', sa.Column('scope', sa.String(get_schema_value('SCOPE_LENGTH'))), sa.Column('regexp', sa.String(255)), - sa.Column('convention_type', sa.Enum(KeyType, name='CVT_TYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('convention_type', sa.Enum(KeyType, + name='CVT_TYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow), sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow)) create_primary_key('NAMING_CONVENTIONS_PK', 'naming_conventions', ['scope']) diff --git a/lib/rucio/db/sqla/migrate_repo/versions/3152492b110b_added_staging_area_column.py b/lib/rucio/db/sqla/migrate_repo/versions/3152492b110b_added_staging_area_column.py index 7d22b6333d..40ac7f7d81 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/3152492b110b_added_staging_area_column.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/3152492b110b_added_staging_area_column.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,10 +14,11 @@ # limitations under the License. # # Authors: -# - Vincent Garonne , 2015-2017 +# - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016 # - Mario Lassnig , 2019-2021 # - Robert Illingworth , 2019 +# - Benedikt Ziemons , 2021 ''' added staging_area column ''' @@ -39,19 +41,19 @@ def upgrade(): schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else '' if context.get_context().dialect.name == 'oracle': - add_column('rses', sa.Column('staging_area', sa.Boolean(name='RSE_STAGING_AREA_CHK'), default=False)) + add_column('rses', sa.Column('staging_area', sa.Boolean(name='RSE_STAGING_AREA_CHK', create_constraint=True), default=False)) try_drop_constraint('REQUESTS_TYPE_CHK', 'requests') create_check_constraint(constraint_name='REQUESTS_TYPE_CHK', table_name='requests', condition="request_type in ('U', 'D', 'T', 'I', '0')") elif context.get_context().dialect.name == 'postgresql': - add_column('rses', sa.Column('staging_area', sa.Boolean(name='RSE_STAGING_AREA_CHK'), default=False), schema=schema[:-1]) + add_column('rses', sa.Column('staging_area', sa.Boolean(name='RSE_STAGING_AREA_CHK', create_constraint=True), default=False), schema=schema[:-1]) drop_constraint('REQUESTS_TYPE_CHK', 'requests', type_='check') create_check_constraint(constraint_name='REQUESTS_TYPE_CHK', table_name='requests', condition="request_type in ('U', 'D', 'T', 'I', '0')") elif context.get_context().dialect.name == 'mysql': - add_column('rses', sa.Column('staging_area', sa.Boolean(name='RSE_STAGING_AREA_CHK'), default=False), schema=schema[:-1]) + add_column('rses', sa.Column('staging_area', sa.Boolean(name='RSE_STAGING_AREA_CHK', create_constraint=True), default=False), schema=schema[:-1]) op.execute('ALTER TABLE ' + schema + 'requests DROP CHECK REQUESTS_TYPE_CHK') # pylint: disable=no-member create_check_constraint(constraint_name='REQUESTS_TYPE_CHK', table_name='requests', condition="request_type in ('U', 'D', 'T', 'I', '0')") diff --git a/lib/rucio/db/sqla/migrate_repo/versions/384b96aa0f60_created_rule_history_tables.py b/lib/rucio/db/sqla/migrate_repo/versions/384b96aa0f60_created_rule_history_tables.py index 691722e448..77f2be1ec3 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/384b96aa0f60_created_rule_history_tables.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/384b96aa0f60_created_rule_history_tables.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2020 CERN +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016 # - Mario Lassnig , 2019-2020 +# - Benedikt Ziemons , 2021 ''' created rule history tables ''' @@ -49,8 +50,14 @@ def upgrade(): sa.Column('account', sa.String(25)), sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), - sa.Column('did_type', sa.Enum(DIDType, name='RULES_HIST_RECENT_DIDTYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), - sa.Column('state', sa.Enum(RuleState, name='RULES_HIST_RECENT_STATE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='RULES_HIST_RECENT_DIDTYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), + sa.Column('state', sa.Enum(RuleState, + name='RULES_HIST_RECENT_STATE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('error', sa.String(255)), sa.Column('rse_expression', sa.String(255)), sa.Column('copies', sa.SmallInteger), @@ -62,8 +69,14 @@ def upgrade(): sa.Column('locks_stuck_cnt', sa.BigInteger), sa.Column('source_replica_expression', sa.String(255)), sa.Column('activity', sa.String(50)), - sa.Column('grouping', sa.Enum(RuleGrouping, name='RULES_HIST_RECENT_GROUPING_CHK', values_callable=lambda obj: [e.value for e in obj])), - sa.Column('notification', sa.Enum(RuleNotification, name='RULES_HIST_RECENT_NOTIFY_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('grouping', sa.Enum(RuleGrouping, + name='RULES_HIST_RECENT_GROUPING_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), + sa.Column('notification', sa.Enum(RuleNotification, + name='RULES_HIST_RECENT_NOTIFY_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('stuck_at', sa.DateTime), sa.Column('purge_replicas', sa.Boolean()), sa.Column('ignore_availability', sa.Boolean()), @@ -77,8 +90,14 @@ def upgrade(): sa.Column('account', sa.String(25)), sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), - sa.Column('did_type', sa.Enum(DIDType, name='RULES_HISTORY_DIDTYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), - sa.Column('state', sa.Enum(RuleState, name='RULES_HISTORY_STATE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='RULES_HISTORY_DIDTYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), + sa.Column('state', sa.Enum(RuleState, + name='RULES_HISTORY_STATE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('error', sa.String(255)), sa.Column('rse_expression', sa.String(255)), sa.Column('copies', sa.SmallInteger), @@ -90,8 +109,14 @@ def upgrade(): sa.Column('locks_stuck_cnt', sa.BigInteger), sa.Column('source_replica_expression', sa.String(255)), sa.Column('activity', sa.String(50)), - sa.Column('grouping', sa.Enum(RuleGrouping, name='RULES_HISTORY_GROUPING_CHK', values_callable=lambda obj: [e.value for e in obj])), - sa.Column('notification', sa.Enum(RuleNotification, name='RULES_HISTORY_NOTIFY_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('grouping', sa.Enum(RuleGrouping, + name='RULES_HISTORY_GROUPING_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), + sa.Column('notification', sa.Enum(RuleNotification, + name='RULES_HISTORY_NOTIFY_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('stuck_at', sa.DateTime), sa.Column('purge_replicas', sa.Boolean()), sa.Column('ignore_availability', sa.Boolean()), diff --git a/lib/rucio/db/sqla/migrate_repo/versions/3ad36e2268b0_create_collection_replicas_updates_table.py b/lib/rucio/db/sqla/migrate_repo/versions/3ad36e2268b0_create_collection_replicas_updates_table.py index d6d0d1970f..892e7d5dfc 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/3ad36e2268b0_create_collection_replicas_updates_table.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/3ad36e2268b0_create_collection_replicas_updates_table.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2020 CERN +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016 # - Mario Lassnig , 2019-2020 +# - Benedikt Ziemons , 2021 ''' create collection_replicas_updates table ''' @@ -52,7 +53,9 @@ def upgrade(): sa.Column('id', GUID()), sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), - sa.Column('did_type', sa.Enum(DIDType, name='UPDATED_COL_REP_TYPE_CHK', + sa.Column('did_type', sa.Enum(DIDType, + name='UPDATED_COL_REP_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])), sa.Column('rse_id', GUID()), sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow), diff --git a/lib/rucio/db/sqla/migrate_repo/versions/4207be2fd914_add_notification_column_to_rules.py b/lib/rucio/db/sqla/migrate_repo/versions/4207be2fd914_add_notification_column_to_rules.py index e848689207..36d86104d0 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/4207be2fd914_add_notification_column_to_rules.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/4207be2fd914_add_notification_column_to_rules.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2020 CERN +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016 # - Mario Lassnig , 2019-2020 +# - Benedikt Ziemons , 2021 ''' add notification column to rules ''' @@ -40,7 +41,9 @@ def upgrade(): schema = context.get_context().version_table_schema + '.' if context.get_context().version_table_schema else '' if context.get_context().dialect.name in ['oracle', 'mysql']: - add_column('rules', sa.Column('notification', sa.Enum(RuleNotification, name='RULES_NOTIFICATION_CHK', + add_column('rules', sa.Column('notification', sa.Enum(RuleNotification, + name='RULES_NOTIFICATION_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RuleNotification.NO), schema=schema[:-1]) elif context.get_context().dialect.name == 'postgresql': diff --git a/lib/rucio/db/sqla/migrate_repo/versions/45378a1e76a8_create_collection_replica_table.py b/lib/rucio/db/sqla/migrate_repo/versions/45378a1e76a8_create_collection_replica_table.py index f0145c982c..34d74e5210 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/45378a1e76a8_create_collection_replica_table.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/45378a1e76a8_create_collection_replica_table.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2015-2020 CERN +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Vincent Garonne , 2015-2017 # - Martin Barisits , 2016-2019 # - Mario Lassnig , 2019-2020 +# - Benedikt Ziemons , 2021 ''' create collection replica table ''' @@ -45,11 +46,18 @@ def upgrade(): create_table('collection_replicas', sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), - sa.Column('did_type', sa.Enum(DIDType, name='COLLECTION_REPLICAS_TYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='COLLECTION_REPLICAS_TYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('rse_id', GUID()), sa.Column('bytes', sa.BigInteger), sa.Column('length', sa.BigInteger), - sa.Column('state', sa.Enum(ReplicaState, name='COLLECTION_REPLICAS_STATE_CHK', values_callable=lambda obj: [e.value for e in obj]), default=ReplicaState.UNAVAILABLE), + sa.Column('state', sa.Enum(ReplicaState, + name='COLLECTION_REPLICAS_STATE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj]), + default=ReplicaState.UNAVAILABLE), sa.Column('accessed_at', sa.DateTime), sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow), sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow)) diff --git a/lib/rucio/db/sqla/migrate_repo/versions/4cf0a2e127d4_adding_transient_metadata.py b/lib/rucio/db/sqla/migrate_repo/versions/4cf0a2e127d4_adding_transient_metadata.py index 85bc5353b9..f792fe8d11 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/4cf0a2e127d4_adding_transient_metadata.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/4cf0a2e127d4_adding_transient_metadata.py @@ -1,4 +1,5 @@ -# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,9 +14,10 @@ # limitations under the License. # # Authors: -# - Vincent Garonne , 2014-2017 -# - Cedric Serfon , 2015 +# - Vincent Garonne , 2015-2017 +# - Martin Barisits , 2016 # - Mario Lassnig , 2019 +# - Benedikt Ziemons , 2021 ''' adding transient metadata ''' @@ -37,7 +39,7 @@ def upgrade(): if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - add_column('dids', sa.Column('transient', sa.Boolean(name='DID_TRANSIENT_CHK'), server_default='0'), schema=schema) + add_column('dids', sa.Column('transient', sa.Boolean(name='DID_TRANSIENT_CHK', create_constraint=True), server_default='0'), schema=schema) def downgrade(): diff --git a/lib/rucio/db/sqla/migrate_repo/versions/6e572a9bfbf3_add_new_split_container_column_to_rules.py b/lib/rucio/db/sqla/migrate_repo/versions/6e572a9bfbf3_add_new_split_container_column_to_rules.py index 290ed164d4..92c519db2b 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/6e572a9bfbf3_add_new_split_container_column_to_rules.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/6e572a9bfbf3_add_new_split_container_column_to_rules.py @@ -1,4 +1,5 @@ -# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2016-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ # - Martin Barisits , 2016 # - Vincent Garonne , 2017 # - Mario Lassnig , 2019 +# - Benedikt Ziemons , 2021 ''' add new split_container column to rules ''' @@ -37,7 +39,7 @@ def upgrade(): if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - add_column('rules', sa.Column('split_container', sa.Boolean(name='RULES_SPLIT_CONTAINER_CHK'), default=False), schema=schema) + add_column('rules', sa.Column('split_container', sa.Boolean(name='RULES_SPLIT_CONTAINER_CHK', create_constraint=True), default=False), schema=schema) add_column('rules_hist_recent', sa.Column('split_container', sa.Boolean()), schema=schema) add_column('rules_history', sa.Column('split_container', sa.Boolean()), schema=schema) diff --git a/lib/rucio/db/sqla/migrate_repo/versions/7541902bf173_add_didsfollowed_and_followevents_table.py b/lib/rucio/db/sqla/migrate_repo/versions/7541902bf173_add_didsfollowed_and_followevents_table.py index ad539ac86c..1d7a9f2b6f 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/7541902bf173_add_didsfollowed_and_followevents_table.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/7541902bf173_add_didsfollowed_and_followevents_table.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2019-2020 CERN +# Copyright 2019-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Ruturaj Gujar , 2019 # - Martin Barisits , 2019 # - Mario Lassnig , 2020 +# - Benedikt Ziemons , 2021 ''' add DidsFollowed and FollowEvents table ''' @@ -44,7 +45,10 @@ def upgrade(): sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), sa.Column('account', sa.String(25)), - sa.Column('did_type', sa.Enum(DIDType, name='DIDS_FOLLOWED_TYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='DIDS_FOLLOWED_TYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow), sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow)) @@ -64,7 +68,10 @@ def upgrade(): sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), sa.Column('account', sa.String(25)), - sa.Column('did_type', sa.Enum(DIDType, name='DIDS_FOLLOWED_EVENTS_TYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='DIDS_FOLLOWED_EVENTS_TYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('event_type', sa.String(1024)), sa.Column('payload', sa.Text), sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow), diff --git a/lib/rucio/db/sqla/migrate_repo/versions/914b8f02df38_new_table_for_lifetime_model_exceptions.py b/lib/rucio/db/sqla/migrate_repo/versions/914b8f02df38_new_table_for_lifetime_model_exceptions.py index 884fc6e808..b5263fe5d6 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/914b8f02df38_new_table_for_lifetime_model_exceptions.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/914b8f02df38_new_table_for_lifetime_model_exceptions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2016-2020 CERN +# Copyright 2016-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ # - Cedric Serfon , 2016 # - Vincent Garonne , 2017 # - Mario Lassnig , 2019-2020 +# - Benedikt Ziemons , 2021 ''' new table for lifetime model exceptions ''' @@ -47,11 +48,17 @@ def upgrade(): sa.Column('id', GUID()), sa.Column('scope', sa.String(25)), sa.Column('name', sa.String(255)), - sa.Column('did_type', sa.Enum(DIDType, name='LIFETIME_EXCEPT_TYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='LIFETIME_EXCEPT_TYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('account', sa.String(25)), sa.Column('comments', sa.String(4000)), sa.Column('pattern', sa.String(255)), - sa.Column('state', sa.Enum(LifetimeExceptionsState, name='LIFETIME_EXCEPT_STATE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('state', sa.Enum(LifetimeExceptionsState, + name='LIFETIME_EXCEPT_STATE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow), sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow), sa.Column('expires_at', sa.DateTime)) diff --git a/lib/rucio/db/sqla/migrate_repo/versions/a5f6f6e928a7_1_7_0.py b/lib/rucio/db/sqla/migrate_repo/versions/a5f6f6e928a7_1_7_0.py index 0f3a8bff42..a652756201 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/a5f6f6e928a7_1_7_0.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/a5f6f6e928a7_1_7_0.py @@ -1,4 +1,5 @@ -# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2016-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +16,7 @@ # Authors: # - Vincent Garonne , 2016-2017 # - Mario Lassnig , 2019 +# - Benedikt Ziemons , 2021 ''' add columns for 1.7.0 release ''' @@ -37,12 +39,12 @@ def upgrade(): if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' add_column('dids', sa.Column('purge_replicas', - sa.Boolean(name='DIDS_PURGE_RPLCS_CHK'), + sa.Boolean(name='DIDS_PURGE_RPLCS_CHK', create_constraint=True), server_default='1'), schema=schema) add_column('dids', sa.Column('eol_at', sa.DateTime), schema=schema) add_column('deleted_dids', sa.Column('purge_replicas', - sa.Boolean(name='DEL_DIDS_PURGE_RPLCS_CHK')), schema=schema) + sa.Boolean(name='DEL_DIDS_PURGE_RPLCS_CHK', create_constraint=True)), schema=schema) add_column('deleted_dids', sa.Column('eol_at', sa.DateTime), schema=schema) create_check_constraint('DIDS_PURGE_REPLICAS_NN', 'dids', 'purge_replicas is not null') diff --git a/lib/rucio/db/sqla/migrate_repo/versions/b96a1c7e1cc4_new_bad_pfns_table_and_bad_replicas_.py b/lib/rucio/db/sqla/migrate_repo/versions/b96a1c7e1cc4_new_bad_pfns_table_and_bad_replicas_.py index 645c57e88b..39fb5a25da 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/b96a1c7e1cc4_new_bad_pfns_table_and_bad_replicas_.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/b96a1c7e1cc4_new_bad_pfns_table_and_bad_replicas_.py @@ -17,6 +17,7 @@ # - Martin Barisits , 2018-2019 # - Mario Lassnig , 2019-2021 # - Robert Illingworth , 2019 +# - Benedikt Ziemons , 2021 ''' new bad_pfns table and bad_replicas changes ''' @@ -48,7 +49,11 @@ def upgrade(): # Create new bad_pfns table create_table('bad_pfns', sa.Column('path', sa.String(2048)), - sa.Column('state', sa.Enum(BadPFNStatus, name='BAD_PFNS_STATE_CHK', values_callable=lambda obj: [e.value for e in obj]), default=BadPFNStatus.SUSPICIOUS), + sa.Column('state', sa.Enum(BadPFNStatus, + name='BAD_PFNS_STATE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj]), + default=BadPFNStatus.SUSPICIOUS), sa.Column('reason', sa.String(255)), sa.Column('account', sa.String(25)), sa.Column('expires_at', sa.DateTime), @@ -76,7 +81,11 @@ def upgrade(): # Create new bad_pfns table create_table('bad_pfns', sa.Column('path', sa.String(2048)), - sa.Column('state', sa.Enum(BadPFNStatus, name='BAD_PFNS_STATE_CHK', values_callable=lambda obj: [e.value for e in obj]), default=BadPFNStatus.SUSPICIOUS), + sa.Column('state', sa.Enum(BadPFNStatus, + name='BAD_PFNS_STATE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj]), + default=BadPFNStatus.SUSPICIOUS), sa.Column('reason', sa.String(255)), sa.Column('account', sa.String(25)), sa.Column('expires_at', sa.DateTime), diff --git a/lib/rucio/db/sqla/migrate_repo/versions/ccdbcd48206e_add_did_type_column_index_on_did_meta_.py b/lib/rucio/db/sqla/migrate_repo/versions/ccdbcd48206e_add_did_type_column_index_on_did_meta_.py index 2bf494c82e..89557a46d6 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/ccdbcd48206e_add_did_type_column_index_on_did_meta_.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/ccdbcd48206e_add_did_type_column_index_on_did_meta_.py @@ -1,4 +1,5 @@ -# Copyright 2013-2020 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +15,7 @@ # # Authors: # - Cedric Serfon , 2021 +# - Benedikt Ziemons , 2021 ''' Add did_type column + index on did_meta table ''' @@ -40,7 +42,10 @@ def upgrade(): schema = get_context().version_table_schema + '.' if get_context().version_table_schema else '' if get_context().dialect.name in ['oracle', 'mysql']: add_column('did_meta', - sa.Column('did_type', sa.Enum(DIDType, name='DID_META_DID_TYPE_CHK', values_callable=lambda obj: [e.value for e in obj])), + sa.Column('did_type', sa.Enum(DIDType, + name='DID_META_DID_TYPE_CHK', + create_constraint=True, + values_callable=lambda obj: [e.value for e in obj])), schema=schema[:-1]) elif get_context().dialect.name == 'postgresql': execute("CREATE TYPE \"DID_META_DID_TYPE_CHK\" AS ENUM('F', 'D', 'C', 'A', 'X', 'Y', 'Z')") diff --git a/lib/rucio/db/sqla/migrate_repo/versions/d1189a09c6e0_oauth2_0_and_jwt_feature_support_adding_.py b/lib/rucio/db/sqla/migrate_repo/versions/d1189a09c6e0_oauth2_0_and_jwt_feature_support_adding_.py index e64feca715..84d4eb4732 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/d1189a09c6e0_oauth2_0_and_jwt_feature_support_adding_.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/d1189a09c6e0_oauth2_0_and_jwt_feature_support_adding_.py @@ -17,6 +17,7 @@ # - Jaroslav Guenther , 2019-2020 # - Martin Barisits , 2020 # - Mario Lassnig , 2020-2021 +# - Benedikt Ziemons , 2021 ''' OAuth2.0 and JWT feature support; adding table oauth_requests & several columns to tokens table ''' @@ -64,7 +65,7 @@ def upgrade(): add_column('tokens', sa.Column('oidc_scope', sa.String(2048), nullable=True, default=None), schema=schema[:-1]) add_column('tokens', sa.Column('audience', sa.String(315), nullable=True, default=None), schema=schema[:-1]) add_column('tokens', sa.Column('refresh_token', sa.String(315), nullable=True, default=None), schema=schema[:-1]) - add_column('tokens', sa.Column('refresh', sa.Boolean(name='TOKENS_REFRESH_CHK'), default=False), schema=schema[:-1]) + add_column('tokens', sa.Column('refresh', sa.Boolean(name='TOKENS_REFRESH_CHK', create_constraint=True), default=False), schema=schema[:-1]) add_column('tokens', sa.Column('refresh_start', sa.DateTime(), nullable=True, default=None), schema=schema[:-1]) add_column('tokens', sa.Column('refresh_expired_at', sa.DateTime(), nullable=True, default=None), schema=schema[:-1]) add_column('tokens', sa.Column('refresh_lifetime', sa.Integer(), nullable=True, default=None), schema=schema[:-1]) diff --git a/lib/rucio/db/sqla/migrate_repo/versions/d6dceb1de2d_added_purge_column_to_rules.py b/lib/rucio/db/sqla/migrate_repo/versions/d6dceb1de2d_added_purge_column_to_rules.py index 6354736573..a77fc5c828 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/d6dceb1de2d_added_purge_column_to_rules.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/d6dceb1de2d_added_purge_column_to_rules.py @@ -1,4 +1,5 @@ -# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2015-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,8 +14,10 @@ # limitations under the License. # # Authors: -# - Martin Barisits , 2014 +# - Vincent Garonne , 2015-2017 +# - Martin Barisits , 2016 # - Mario Lassnig , 2019 +# - Benedikt Ziemons , 2021 ''' added purge column to rules ''' @@ -36,7 +39,7 @@ def upgrade(): if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']: schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' - add_column('rules', sa.Column('purge_replicas', sa.Boolean(name='RULES_PURGE_REPLICAS_CHK'), default=False), schema=schema) + add_column('rules', sa.Column('purge_replicas', sa.Boolean(name='RULES_PURGE_REPLICAS_CHK', create_constraint=True), default=False), schema=schema) create_check_constraint('RULES_PURGE_REPLICAS_NN', 'rules', "PURGE_REPLICAS IS NOT NULL") diff --git a/lib/rucio/db/sqla/migrate_repo/versions/e59300c8b179_support_for_archive.py b/lib/rucio/db/sqla/migrate_repo/versions/e59300c8b179_support_for_archive.py index e683ed8ae9..8405aea2a3 100644 --- a/lib/rucio/db/sqla/migrate_repo/versions/e59300c8b179_support_for_archive.py +++ b/lib/rucio/db/sqla/migrate_repo/versions/e59300c8b179_support_for_archive.py @@ -1,4 +1,5 @@ -# Copyright 2013-2019 CERN for the benefit of the ATLAS collaboration. +# -*- coding: utf-8 -*- +# Copyright 2017-2021 CERN # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,8 +14,9 @@ # limitations under the License. # # Authors: -# - Vincent Garonne , 2015-2017 +# - Vincent Garonne , 2017 # - Mario Lassnig , 2019 +# - Benedikt Ziemons , 2021 ''' support for archive ''' @@ -86,9 +88,11 @@ def upgrade(): schema = context.get_context().version_table_schema if context.get_context().version_table_schema else '' add_column('dids', sa.Column('is_archive', - sa.Boolean(name='DIDS_ARCHIVE_CHK')), schema=schema) + sa.Boolean(name='DIDS_ARCHIVE_CHK', create_constraint=True)), + schema=schema) add_column('dids', sa.Column('constituent', - sa.Boolean(name='DIDS_CONSTITUENT_CHK')), schema=schema) + sa.Boolean(name='DIDS_CONSTITUENT_CHK', create_constraint=True)), + schema=schema) add_column('deleted_dids', sa.Column('is_archive', sa.Boolean()), schema=schema) add_column('deleted_dids', sa.Column('constituent', sa.Boolean()), schema=schema) diff --git a/lib/rucio/db/sqla/models.py b/lib/rucio/db/sqla/models.py index 87de44263f..27bbe3ecb4 100644 --- a/lib/rucio/db/sqla/models.py +++ b/lib/rucio/db/sqla/models.py @@ -17,7 +17,7 @@ # - Vincent Garonne , 2015-2017 # - JoaquĆ­n Bogado , 2015-2019 # - Wen Guan , 2015 -# - Martin Barisits , 2015-2021 +# - Martin Barisits , 2015-2020 # - Cedric Serfon , 2016-2021 # - Mario Lassnig , 2017-2020 # - asket , 2018 @@ -29,6 +29,7 @@ # - James Perry , 2020 # - Benedikt Ziemons , 2020-2021 # - Matt Snyder , 2021 +# - joaquinbogado , 2021 import datetime import sys @@ -313,8 +314,10 @@ class Account(BASE, ModelBase): __tablename__ = 'accounts' account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) account_type = Column(Enum(AccountType, name='ACCOUNTS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) status = Column(Enum(AccountStatus, name='ACCOUNTS_STATUS_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=AccountStatus.ACTIVE, ) email = Column(String(255)) @@ -341,6 +344,7 @@ class Identity(BASE, SoftModelBase): __tablename__ = 'identities' identity = Column(String(2048)) identity_type = Column(Enum(IdentityType, name='IDENTITIES_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) username = Column(String(255)) password = Column(String(255)) @@ -356,9 +360,11 @@ class IdentityAccountAssociation(BASE, ModelBase): __tablename__ = 'account_map' identity = Column(String(2048)) identity_type = Column(Enum(IdentityType, name='ACCOUNT_MAP_ID_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) - is_default = Column(Boolean(name='ACCOUNT_MAP_DEFAULT_CHK'), default=False) + is_default = Column(Boolean(name='ACCOUNT_MAP_DEFAULT_CHK', create_constraint=True), + default=False) _table_args = (PrimaryKeyConstraint('identity', 'identity_type', 'account', name='ACCOUNT_MAP_PK'), ForeignKeyConstraint(['account'], ['accounts.account'], name='ACCOUNT_MAP_ACCOUNT_FK'), ForeignKeyConstraint(['identity', 'identity_type'], ['identities.identity', 'identities.identity_type'], name='ACCOUNT_MAP_ID_TYPE_FK'), @@ -371,8 +377,10 @@ class Scope(BASE, ModelBase): __tablename__ = 'scopes' scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) - is_default = Column(Boolean(name='SCOPES_DEFAULT_CHK'), default=False) + is_default = Column(Boolean(name='SCOPES_DEFAULT_CHK', create_constraint=True), + default=False) status = Column(Enum(ScopeStatus, name='SCOPE_STATUS_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=ScopeStatus.OPEN) closed_at = Column(DateTime) @@ -391,23 +399,32 @@ class DataIdentifier(BASE, ModelBase): name = Column(String(get_schema_value('NAME_LENGTH'))) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) did_type = Column(Enum(DIDType, name='DIDS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) - is_open = Column(Boolean(name='DIDS_IS_OPEN_CHK')) - monotonic = Column(Boolean(name='DIDS_MONOTONIC_CHK'), server_default='0') - hidden = Column(Boolean(name='DIDS_HIDDEN_CHK'), server_default='0') - obsolete = Column(Boolean(name='DIDS_OBSOLETE_CHK'), server_default='0') - complete = Column(Boolean(name='DIDS_COMPLETE_CHK'), server_default=None) - is_new = Column(Boolean(name='DIDS_IS_NEW_CHK'), server_default='1') + is_open = Column(Boolean(name='DIDS_IS_OPEN_CHK', create_constraint=True)) + monotonic = Column(Boolean(name='DIDS_MONOTONIC_CHK', create_constraint=True), + server_default='0') + hidden = Column(Boolean(name='DIDS_HIDDEN_CHK', create_constraint=True), + server_default='0') + obsolete = Column(Boolean(name='DIDS_OBSOLETE_CHK', create_constraint=True), + server_default='0') + complete = Column(Boolean(name='DIDS_COMPLETE_CHK', create_constraint=True), + server_default=None) + is_new = Column(Boolean(name='DIDS_IS_NEW_CHK', create_constraint=True), + server_default='1') availability = Column(Enum(DIDAvailability, name='DIDS_AVAILABILITY_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=DIDAvailability.AVAILABLE) - suppressed = Column(Boolean(name='FILES_SUPP_CHK'), server_default='0') + suppressed = Column(Boolean(name='FILES_SUPP_CHK', create_constraint=True), + server_default='0') bytes = Column(BigInteger) length = Column(BigInteger) md5 = Column(String(32)) adler32 = Column(String(8)) expired_at = Column(DateTime) - purge_replicas = Column(Boolean(name='DIDS_PURGE_RPLCS_CHK'), server_default='1') + purge_replicas = Column(Boolean(name='DIDS_PURGE_RPLCS_CHK', create_constraint=True), + server_default='1') deleted_at = Column(DateTime) # hardcoded meta-data to populate the db events = Column(BigInteger) @@ -424,12 +441,13 @@ class DataIdentifier(BASE, ModelBase): lumiblocknr = Column(Integer()) provenance = Column(String(2)) phys_group = Column(String(25)) - transient = Column(Boolean(name='DID_TRANSIENT_CHK'), server_default='0') + transient = Column(Boolean(name='DID_TRANSIENT_CHK', create_constraint=True), + server_default='0') accessed_at = Column(DateTime) closed_at = Column(DateTime) eol_at = Column(DateTime) - is_archive = Column(Boolean(name='DIDS_ARCHIVE_CHK')) - constituent = Column(Boolean(name='DIDS_CONSTITUENT_CHK')) + is_archive = Column(Boolean(name='DIDS_ARCHIVE_CHK', create_constraint=True)) + constituent = Column(Boolean(name='DIDS_CONSTITUENT_CHK', create_constraint=True)) access_cnt = Column(Integer()) _table_args = (PrimaryKeyConstraint('scope', 'name', name='DIDS_PK'), ForeignKeyConstraint(['account'], ['accounts.account'], ondelete='CASCADE', name='DIDS_ACCOUNT_FK'), @@ -449,6 +467,7 @@ class DidMeta(BASE, ModelBase): name = Column(String(get_schema_value('NAME_LENGTH'))) meta = Column(JSON()) did_type = Column(Enum(DIDType, name='DID_META_DID_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) _table_args = (PrimaryKeyConstraint('scope', 'name', name='DID_META_PK'), ForeignKeyConstraint(['scope', 'name'], ['dids.scope', 'dids.name'], name='DID_META_FK'), @@ -462,17 +481,24 @@ class DeletedDataIdentifier(BASE, ModelBase): name = Column(String(get_schema_value('NAME_LENGTH'))) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) did_type = Column(Enum(DIDType, name='DEL_DIDS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) - is_open = Column(Boolean(name='DEL_DIDS_IS_OPEN_CHK')) - monotonic = Column(Boolean(name='DEL_DIDS_MONO_CHK'), server_default='0') - hidden = Column(Boolean(name='DEL_DIDS_HIDDEN_CHK'), server_default='0') - obsolete = Column(Boolean(name='DEL_DIDS_OBSOLETE_CHK'), server_default='0') - complete = Column(Boolean(name='DEL_DIDS_COMPLETE_CHK')) - is_new = Column(Boolean(name='DEL_DIDS_IS_NEW_CHK'), server_default='1') + is_open = Column(Boolean(name='DEL_DIDS_IS_OPEN_CHK', create_constraint=True)) + monotonic = Column(Boolean(name='DEL_DIDS_MONO_CHK', create_constraint=True), + server_default='0') + hidden = Column(Boolean(name='DEL_DIDS_HIDDEN_CHK', create_constraint=True), + server_default='0') + obsolete = Column(Boolean(name='DEL_DIDS_OBSOLETE_CHK', create_constraint=True), + server_default='0') + complete = Column(Boolean(name='DEL_DIDS_COMPLETE_CHK', create_constraint=True)) + is_new = Column(Boolean(name='DEL_DIDS_IS_NEW_CHK', create_constraint=True), + server_default='1') availability = Column(Enum(DIDAvailability, name='DEL_DIDS_AVAIL_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=DIDAvailability.AVAILABLE) - suppressed = Column(Boolean(name='DEL_FILES_SUPP_CHK'), server_default='0') + suppressed = Column(Boolean(name='DEL_FILES_SUPP_CHK', create_constraint=True), + server_default='0') bytes = Column(BigInteger) length = Column(BigInteger) md5 = Column(String(32)) @@ -493,13 +519,14 @@ class DeletedDataIdentifier(BASE, ModelBase): lumiblocknr = Column(Integer()) provenance = Column(String(2)) phys_group = Column(String(25)) - transient = Column(Boolean(name='DEL_DID_TRANSIENT_CHK'), server_default='0') - purge_replicas = Column(Boolean(name='DELETED_DIDS_PURGE_RPLCS_CHK')) + transient = Column(Boolean(name='DEL_DID_TRANSIENT_CHK', create_constraint=True), + server_default='0') + purge_replicas = Column(Boolean(name='DELETED_DIDS_PURGE_RPLCS_CHK', create_constraint=True)) accessed_at = Column(DateTime) closed_at = Column(DateTime) eol_at = Column(DateTime) - is_archive = Column(Boolean(name='DEL_DIDS_ARCH_CHK')) - constituent = Column(Boolean(name='DEL_DIDS_CONST_CHK')) + is_archive = Column(Boolean(name='DEL_DIDS_ARCH_CHK', create_constraint=True)) + constituent = Column(Boolean(name='DEL_DIDS_CONST_CHK', create_constraint=True)) access_cnt = Column(Integer()) _table_args = (PrimaryKeyConstraint('scope', 'name', name='DELETED_DIDS_PK'), ) @@ -511,6 +538,7 @@ class UpdatedDID(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) rule_evaluation_action = Column(Enum(DIDReEvaluation, name='UPDATED_DIDS_RULE_EVAL_ACT_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) _table_args = (PrimaryKeyConstraint('id', name='UPDATED_DIDS_PK'), CheckConstraint('SCOPE IS NOT NULL', name='UPDATED_DIDS_SCOPE_NN'), @@ -526,6 +554,7 @@ class BadReplicas(BASE, ModelBase): rse_id = Column(GUID()) reason = Column(String(255)) state = Column(Enum(BadFilesStatus, name='BAD_REPLICAS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=BadFilesStatus.SUSPICIOUS) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) @@ -546,6 +575,7 @@ class BadPFNs(BASE, ModelBase): __tablename__ = 'bad_pfns' path = Column(String(2048)) # PREFIX + PFN state = Column(Enum(BadPFNStatus, name='BAD_PFNS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=BadPFNStatus.SUSPICIOUS) reason = Column(String(255)) @@ -591,8 +621,10 @@ class DIDKey(BASE, ModelBase): """Represents Data IDentifier property keys""" __tablename__ = 'did_keys' key = Column(String(255)) - is_enum = Column(Boolean(name='DID_KEYS_IS_ENUM_CHK'), server_default='0') + is_enum = Column(Boolean(name='DID_KEYS_IS_ENUM_CHK', create_constraint=True), + server_default='0') key_type = Column(Enum(KeyType, name='DID_KEYS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) value_type = Column(String(255)) value_regexp = Column(String(255)) @@ -618,15 +650,17 @@ class DataIdentifierAssociation(BASE, ModelBase): child_scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Provenance scope child_name = Column(String(get_schema_value('NAME_LENGTH'))) # Provenance name did_type = Column(Enum(DIDType, name='CONTENTS_DID_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) child_type = Column(Enum(DIDType, name='CONTENTS_CHILD_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) bytes = Column(BigInteger) adler32 = Column(String(8)) md5 = Column(String(32)) guid = Column(GUID()) events = Column(BigInteger) - rule_evaluation = Column(Boolean(name='CONTENTS_RULE_EVALUATION_CHK')) + rule_evaluation = Column(Boolean(name='CONTENTS_RULE_EVALUATION_CHK', create_constraint=True)) _table_args = (PrimaryKeyConstraint('scope', 'name', 'child_scope', 'child_name', name='CONTENTS_PK'), ForeignKeyConstraint(['scope', 'name'], ['dids.scope', 'dids.name'], name='CONTENTS_ID_FK'), ForeignKeyConstraint(['child_scope', 'child_name'], ['dids.scope', 'dids.name'], ondelete="CASCADE", name='CONTENTS_CHILD_ID_FK'), @@ -685,15 +719,17 @@ class DataIdentifierAssociationHistory(BASE, ModelBase): child_scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) # Provenance scope child_name = Column(String(get_schema_value('NAME_LENGTH'))) # Provenance name did_type = Column(Enum(DIDType, name='CONTENTS_HIST_DID_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) child_type = Column(Enum(DIDType, name='CONTENTS_HIST_CHILD_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) bytes = Column(BigInteger) adler32 = Column(String(8)) md5 = Column(String(32)) guid = Column(GUID()) events = Column(BigInteger) - rule_evaluation = Column(Boolean(name='CONTENTS_HIST_RULE_EVAL_CHK')) + rule_evaluation = Column(Boolean(name='CONTENTS_HIST_RULE_EVAL_CHK', create_constraint=True)) did_created_at = Column(DateTime) deleted_at = Column(DateTime) __mapper_args__ = { @@ -711,11 +747,15 @@ class RSE(BASE, SoftModelBase): rse = Column(String(255)) vo = Column(String(3), nullable=False, server_default='def') rse_type = Column(Enum(RSEType, name='RSES_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RSEType.DISK) - deterministic = Column(Boolean(name='RSE_DETERMINISTIC_CHK'), default=True) - volatile = Column(Boolean(name='RSE_VOLATILE_CHK'), default=False) - staging_area = Column(Boolean(name='RSE_STAGING_AREA_CHK'), default=False) + deterministic = Column(Boolean(name='RSE_DETERMINISTIC_CHK', create_constraint=True), + default=True) + volatile = Column(Boolean(name='RSE_VOLATILE_CHK', create_constraint=True), + default=False) + staging_area = Column(Boolean(name='RSE_STAGING_AREA_CHK', create_constraint=True), + default=False) city = Column(String(255)) region_code = Column(String(2)) country_name = Column(String(255)) @@ -895,6 +935,7 @@ class RSEFileAssociation(BASE, ModelBase): adler32 = Column(String(8)) path = Column(String(1024)) state = Column(Enum(ReplicaState, name='REPLICAS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=ReplicaState.UNAVAILABLE) lock_cnt = Column(Integer, server_default='0') @@ -918,6 +959,7 @@ class CollectionReplica(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='COLLECTION_REPLICAS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) rse_id = Column(GUID()) bytes = Column(BigInteger) @@ -925,6 +967,7 @@ class CollectionReplica(BASE, ModelBase): available_bytes = Column(BigInteger) available_replicas_cnt = Column(BigInteger) state = Column(Enum(ReplicaState, name='COLLECTION_REPLICAS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=ReplicaState.UNAVAILABLE) accessed_at = Column(DateTime) @@ -943,6 +986,7 @@ class UpdatedCollectionReplica(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='UPDATED_COL_REP_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) rse_id = Column(GUID()) _table_args = (PrimaryKeyConstraint('id', name='UPDATED_COL_REP_PK'), @@ -972,8 +1016,10 @@ class ReplicationRule(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='RULES_DID_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) state = Column(Enum(RuleState, name='RULES_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RuleState.REPLICATING) error = Column(String(255)) @@ -981,27 +1027,34 @@ class ReplicationRule(BASE, ModelBase): copies = Column(SmallInteger, server_default='1') expires_at = Column(DateTime) weight = Column(String(255)) - locked = Column(Boolean(name='RULES_LOCKED_CHK'), default=False) + locked = Column(Boolean(name='RULES_LOCKED_CHK', create_constraint=True), + default=False) locks_ok_cnt = Column(BigInteger, server_default='0') locks_replicating_cnt = Column(BigInteger, server_default='0') locks_stuck_cnt = Column(BigInteger, server_default='0') source_replica_expression = Column(String(255)) activity = Column(String(50), default='default') grouping = Column(Enum(RuleGrouping, name='RULES_GROUPING_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RuleGrouping.ALL) notification = Column(Enum(RuleNotification, name='RULES_NOTIFICATION_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RuleNotification.NO) stuck_at = Column(DateTime) - purge_replicas = Column(Boolean(name='RULES_PURGE_REPLICAS_CHK'), default=False) - ignore_availability = Column(Boolean(name='RULES_IGNORE_AVAILABILITY_CHK'), default=False) - ignore_account_limit = Column(Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK'), default=False) + purge_replicas = Column(Boolean(name='RULES_PURGE_REPLICAS_CHK', create_constraint=True), + default=False) + ignore_availability = Column(Boolean(name='RULES_IGNORE_AVAILABILITY_CHK', create_constraint=True), + default=False) + ignore_account_limit = Column(Boolean(name='RULES_IGNORE_ACCOUNT_LIMIT_CHK', create_constraint=True), + default=False) priority = Column(Integer) comments = Column(String(255)) child_rule_id = Column(GUID()) eol_at = Column(DateTime) - split_container = Column(Boolean(name='RULES_SPLIT_CONTAINER_CHK'), default=False) + split_container = Column(Boolean(name='RULES_SPLIT_CONTAINER_CHK', create_constraint=True), + default=False) meta = Column(String(4000)) _table_args = (PrimaryKeyConstraint('id', name='RULES_PK'), ForeignKeyConstraint(['scope', 'name'], ['dids.scope', 'dids.name'], name='RULES_SCOPE_NAME_FK'), @@ -1036,8 +1089,10 @@ class ReplicationRuleHistoryRecent(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='RULES_HIST_RECENT_DIDTYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) state = Column(Enum(RuleState, name='RULES_HIST_RECENT_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) error = Column(String(255)) rse_expression = Column(String(3000)) @@ -1051,8 +1106,10 @@ class ReplicationRuleHistoryRecent(BASE, ModelBase): source_replica_expression = Column(String(255)) activity = Column(String(50)) grouping = Column(Enum(RuleGrouping, name='RULES_HIST_RECENT_GROUPING_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) notification = Column(Enum(RuleNotification, name='RULES_HIST_RECENT_NOTIFY_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) stuck_at = Column(DateTime) purge_replicas = Column(Boolean()) @@ -1080,8 +1137,10 @@ class ReplicationRuleHistory(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='RULES_HISTORY_DIDTYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) state = Column(Enum(RuleState, name='RULES_HISTORY_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) error = Column(String(255)) rse_expression = Column(String(3000)) @@ -1095,8 +1154,10 @@ class ReplicationRuleHistory(BASE, ModelBase): source_replica_expression = Column(String(255)) activity = Column(String(50)) grouping = Column(Enum(RuleGrouping, name='RULES_HISTORY_GROUPING_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) notification = Column(Enum(RuleNotification, name='RULES_HISTORY_NOTIFY_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) stuck_at = Column(DateTime) priority = Column(Integer) @@ -1124,6 +1185,7 @@ class ReplicaLock(BASE, ModelBase): account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) bytes = Column(BigInteger) state = Column(Enum(LockState, name='LOCKS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=LockState.REPLICATING) repair_cnt = Column(BigInteger) @@ -1144,6 +1206,7 @@ class DatasetLock(BASE, ModelBase): rse_id = Column(GUID()) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) state = Column(Enum(LockState, name='DATASET_LOCKS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=LockState.REPLICATING) length = Column(BigInteger) @@ -1178,17 +1241,20 @@ class Request(BASE, ModelBase): __tablename__ = 'requests' id = Column(GUID(), default=utils.generate_uuid) request_type = Column(Enum(RequestType, name='REQUESTS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RequestType.TRANSFER) scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='REQUESTS_DIDTYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=DIDType.FILE) dest_rse_id = Column(GUID()) source_rse_id = Column(GUID()) attributes = Column(String(4000)) state = Column(Enum(RequestState, name='REQUESTS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RequestState.QUEUED) external_id = Column(String(64)) @@ -1234,17 +1300,20 @@ class RequestHistory(BASE, ModelBase): __tablename__ = 'requests_history' id = Column(GUID(), default=utils.generate_uuid) request_type = Column(Enum(RequestType, name='REQUESTS_HIST_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RequestType.TRANSFER) scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='REQUESTS_HIST_DIDTYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=DIDType.FILE) dest_rse_id = Column(GUID()) source_rse_id = Column(GUID()) attributes = Column(String(4000)) state = Column(Enum(RequestState, name='REQUESTS_HIST_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=RequestState.QUEUED) external_id = Column(String(64)) @@ -1354,13 +1423,15 @@ class Subscription(BASE, ModelBase): replication_rules = Column(String(4000)) policyid = Column(SmallInteger, server_default='0') state = Column(Enum(SubscriptionState, name='SUBSCRIPTIONS_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=SubscriptionState.ACTIVE) last_processed = Column(DateTime, default=datetime.datetime.utcnow()) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) lifetime = Column(DateTime) comments = Column(String(4000)) - retroactive = Column(Boolean(name='SUBSCRIPTIONS_RETROACTIVE_CHK'), default=False) + retroactive = Column(Boolean(name='SUBSCRIPTIONS_RETROACTIVE_CHK', create_constraint=True), + default=False) expired_at = Column(DateTime) _table_args = (PrimaryKeyConstraint('id', name='SUBSCRIPTIONS_PK'), UniqueConstraint('name', 'account', name='SUBSCRIPTIONS_NAME_ACCOUNT_UQ'), @@ -1379,13 +1450,15 @@ class SubscriptionHistory(BASE, ModelBase): replication_rules = Column(String(4000)) policyid = Column(SmallInteger, server_default='0') state = Column(Enum(SubscriptionState, name='SUBSCRIPTIONS_HIST_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj]), default=SubscriptionState.ACTIVE) last_processed = Column(DateTime, default=datetime.datetime.utcnow()) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) lifetime = Column(DateTime) comments = Column(String(4000)) - retroactive = Column(Boolean(name='SUBSCRIPTIONS_HIST_RETROACTIVE_CHK'), default=False) + retroactive = Column(Boolean(name='SUBS_HISTORY_RETROACTIVE_CHK', create_constraint=True), + default=False) expired_at = Column(DateTime) _table_args = (PrimaryKeyConstraint('id', 'updated_at', name='SUBSCRIPTIONS_PK'),) @@ -1396,7 +1469,8 @@ class Token(BASE, ModelBase): token = Column(String(3072)) # account-identity-appid-uuid -> max length: (+ 30 1 255 1 32 1 32) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) refresh_token = Column(String(315), default=None) - refresh = Column(Boolean(name='TOKENS_REFRESH_CHK'), default=False) + refresh = Column(Boolean(name='TOKENS_REFRESH_CHK', create_constraint=True), + default=False) refresh_start = Column(DateTime, default=None) refresh_expired_at = Column(DateTime, default=None) refresh_lifetime = Column(Integer()) @@ -1502,6 +1576,7 @@ class NamingConvention(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) regexp = Column(String(255)) convention_type = Column(Enum(KeyType, name='CVT_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) _table_args = (PrimaryKeyConstraint('scope', name='NAMING_CONVENTIONS_PK'), ForeignKeyConstraint(['scope'], ['scopes.scope'], name='NAMING_CONVENTIONS_SCOPE_FK')) @@ -1536,11 +1611,13 @@ class LifetimeExceptions(BASE, ModelBase): scope = Column(InternalScopeString(get_schema_value('SCOPE_LENGTH'))) name = Column(String(get_schema_value('NAME_LENGTH'))) did_type = Column(Enum(DIDType, name='LIFETIME_EXCEPT_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) pattern = Column(String(255)) comments = Column(String(4000)) state = Column(Enum(LifetimeExceptionsState, name='LIFETIME_EXCEPT_STATE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) expires_at = Column(DateTime) _table_args = (PrimaryKeyConstraint('id', 'scope', 'name', 'did_type', 'account', name='LIFETIME_EXCEPT_PK'), @@ -1566,6 +1643,7 @@ class DidsFollowed(BASE, ModelBase): name = Column(String(get_schema_value('NAME_LENGTH'))) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) did_type = Column(Enum(DIDType, name='DIDS_FOLLOWED_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) _table_args = (PrimaryKeyConstraint('scope', 'name', 'account', name='DIDS_FOLLOWED_PK'), CheckConstraint('SCOPE IS NOT NULL', name='DIDS_FOLLOWED_SCOPE_NN'), @@ -1583,6 +1661,7 @@ class FollowEvents(BASE, ModelBase): name = Column(String(get_schema_value('NAME_LENGTH'))) account = Column(InternalAccountString(get_schema_value('ACCOUNT_LENGTH'))) did_type = Column(Enum(DIDType, name='DIDS_FOLLOWED_EVENTS_TYPE_CHK', + create_constraint=True, values_callable=lambda obj: [e.value for e in obj])) event_type = Column(String(1024)) payload = Column(Text) diff --git a/tools/add_header b/tools/add_header index d7068563d6..10570e7a91 100755 --- a/tools/add_header +++ b/tools/add_header @@ -216,7 +216,9 @@ def main(arguments): raise RuntimeError('Cannot read file ' + str(MyFile)) from e with open(MyFile, 'w') as modified: - if lines[0].startswith('#!/usr/bin/env'): + if not lines: + print('Empty lines at file', MyFile, file=sys.stderr) + elif lines[0].startswith('#!/usr/bin/env'): modified.write(lines[0]) elif lines[0].rstrip() == '#!/bin/bash': modified.write(lines[0])