From 842d47dcc441919adf052d7ecd794e189aa46ba4 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 16 Feb 2022 11:12:15 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20MAINTAIN:=20Add=20`NotImplemente?= =?UTF-8?q?dError`=20for=20migration=20downgrades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Downgrading storage version is not explicitly supported in aiida-core, or exposed for the user. Previous to #5330, some downgrade functionality was required for testing, since migration tests involved migrating down the global profile, then migrating it back up to the target version. These migrations though were often incomplete, migrating database schema but not the actual data. Now, migration tests are performed by starting with a separate, empty profile, and migrating up. Since these downgrades are no longer required and are un-tested, we replace their content with an explicit `NotImplementedError`. --- .../versions/041a79fc615f_dblog_cleaning.py | 33 +------ .../118349c10896_default_link_label.py | 1 + ...798d4d3_trajectory_symbols_to_attribute.py | 20 +---- ...0c971ae0a3_migrate_builtin_calculations.py | 27 +----- .../versions/162b99bca4a2_drop_dbcalcstate.py | 17 +--- ...31_drop_node_columns_nodeversion_public.py | 6 +- .../1b8ed3425af9_remove_legacy_workflows.py | 88 +------------------ .../versions/1de112340b16_django_parity_1.py | 2 +- .../versions/1de112340b18_django_parity_3.py | 1 + .../1feaea71bd5a_migrate_repository.py | 1 + .../239cea6d2452_provenance_redesign.py | 33 +------ ..._data_migration_legacy_job_calculations.py | 1 + .../34a831f4286d_entry_point_core_prefix.py | 1 + .../35d4ee9a1b0e_code_hidden_attr_to_extra.py | 24 +---- ...b70663_dblog_uuid_uniqueness_constraint.py | 4 +- ...f3d4882837_make_all_uuid_columns_unique.py | 3 +- .../535039300e4a_computer_name_to_label.py | 4 +- ..._adding_indexes_and_constraints_to_the_.py | 9 +- .../61fc0913fae9_remove_node_prefix.py | 15 +--- ...5c2ea1439d_move_data_within_node_module.py | 11 +-- .../versions/70c7d732f1b2_delete_dbpath.py | 26 +----- .../7b38a9e783e7_seal_unsealed_processes.py | 1 + ...8c391c49_calc_job_option_attribute_keys.py | 3 +- ...b25_add_indexes_to_dbworkflowdata_table.py | 5 +- .../91b573400be5_prepare_schema_reset.py | 1 + .../versions/a514d673c163_drop_dblock.py | 12 +-- .../versions/a6048f0ffca8_update_linktypes.py | 2 +- ...group_name_to_label_type_to_type_string.py | 14 +-- .../bf591f31dd12_dbgroup_type_string.py | 11 +-- ...84bcc35_delete_trajectory_symbols_array.py | 33 +------ ...4fdfed416_rename_parameter_data_to_dict.py | 4 +- .../de2eaf6978b4_simplify_user_model.py | 14 +-- .../versions/django_0002_db_state_change.py | 1 + .../versions/django_0003_add_link_type.py | 6 +- ...django_0004_add_daemon_and_uuid_indices.py | 3 +- .../django_0005_add_cmtime_indices.py | 3 +- .../versions/django_0006_delete_dbpath.py | 29 +----- .../versions/django_0007_update_linktypes.py | 1 + .../django_0008_code_hidden_to_extra.py | 1 + .../versions/django_0010_process_type.py | 4 +- .../django_0011_delete_kombu_tables.py | 2 +- .../versions/django_0012_drop_dblock.py | 17 +--- .../versions/django_0013_django_1_8.py | 1 + ...go_0014_add_node_uuid_unique_constraint.py | 3 +- .../versions/django_0017_drop_dbcalcstate.py | 27 +----- .../versions/django_0018_django_1_11.py | 26 +----- ...jango_0019_migrate_builtin_calculations.py | 28 +----- .../django_0020_provenance_redesign.py | 29 +----- ...group_name_to_label_type_to_type_string.py | 30 +------ ...0022_dbgroup_type_string_change_content.py | 9 +- ...ngo_0023_calc_job_option_attribute_keys.py | 46 +--------- .../versions/django_0024a_dblog_update.py | 1 + .../versions/django_0024b_dblog_update.py | 2 +- ...jango_0025_move_data_within_node_module.py | 11 +-- ...go_0026_trajectory_symbols_to_attribute.py | 1 + ...go_0027_delete_trajectory_symbols_array.py | 1 + .../django_0028_remove_node_prefix.py | 15 +--- ...ango_0029_rename_parameter_data_to_dict.py | 9 +- ...go_0030_dbnode_type_to_dbnode_node_type.py | 2 +- .../django_0031_remove_dbcomputer_enabled.py | 5 +- .../django_0032_remove_legacy_workflows.py | 1 + ...0033_replace_text_field_with_json_field.py | 1 + ...34_drop_node_columns_nodeversion_public.py | 6 +- .../django_0035_simplify_user_model.py | 1 + ...ngo_0036_drop_computer_transport_params.py | 1 + ...go_0037_attributes_extras_settings_json.py | 1 + ..._data_migration_legacy_job_calculations.py | 1 + ...ata_migration_legacy_process_attributes.py | 1 + .../django_0041_seal_unsealed_processes.py | 1 + .../django_0042_prepare_schema_reset.py | 1 + .../django_0043_default_link_label.py | 7 +- .../django_0044_dbgroup_type_string.py | 11 +-- .../versions/django_0045_dbgroup_extras.py | 4 +- .../django_0047_migrate_repository.py | 1 + .../django_0048_computer_name_to_label.py | 12 +-- .../django_0049_entry_point_core_prefix.py | 1 + .../versions/django_0050_sqlalchemy_parity.py | 1 + ...dbgroup_class_change_type_string_values.py | 2 + ...ata_migration_legacy_process_attributes.py | 1 + .../f9a69de76a9a_delete_kombu_tables.py | 2 +- .../migrations/versions/main_0001_initial.py | 2 +- .../sqlalchemy_branch/test_4_dblog_update.py | 85 ------------------ 82 files changed, 106 insertions(+), 778 deletions(-) diff --git a/aiida/backends/sqlalchemy/migrations/versions/041a79fc615f_dblog_cleaning.py b/aiida/backends/sqlalchemy/migrations/versions/041a79fc615f_dblog_cleaning.py index 7f86c0bf8e..01a80b5769 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/041a79fc615f_dblog_cleaning.py +++ b/aiida/backends/sqlalchemy/migrations/versions/041a79fc615f_dblog_cleaning.py @@ -73,35 +73,4 @@ def downgrade(): """ Downgrade function to the previous schema. """ - # Create an empty column objname (the data is permanently lost) - op.add_column('db_dblog', sa.Column('objname', sa.VARCHAR(length=255), autoincrement=False, nullable=True)) - op.create_index('ix_db_dblog_objname', 'db_dblog', ['objname']) - - # Creating a column objpk - - op.add_column('db_dblog', sa.Column('objpk', sa.INTEGER(), autoincrement=False, nullable=True)) - - # Copy the data back to objpk from dbnode_id - op.execute(text("""UPDATE db_dblog SET objpk=dbnode_id""")) - - # Removing the column dbnode_id - op.drop_column('db_dblog', 'dbnode_id') - - # Populate objname with correct values - op.execute( - text("""UPDATE db_dblog SET objname=db_dbnode.type - FROM db_dbnode WHERE db_dbnode.id = db_dblog.objpk""") - ) - - # Enrich metadata with objpk and objname if these keys don't exist - op.execute( - text( - """UPDATE db_dblog SET metadata = jsonb_set(metadata, '{"objpk"}', to_jsonb(objpk)) - WHERE NOT (metadata ?| '{"objpk"}') """ - ) - ) - op.execute( - text( - """UPDATE db_dblog SET metadata = jsonb_set(metadata, '{"objname"}', to_jsonb(objname)) - WHERE NOT (metadata ?| '{"objname"}') """ - ) - ) + raise NotImplementedError('Downgrade of 041a79fc615f.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/118349c10896_default_link_label.py b/aiida/backends/sqlalchemy/migrations/versions/118349c10896_default_link_label.py index 05e248a69c..b09a1b1120 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/118349c10896_default_link_label.py +++ b/aiida/backends/sqlalchemy/migrations/versions/118349c10896_default_link_label.py @@ -47,3 +47,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 118349c10896.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/12536798d4d3_trajectory_symbols_to_attribute.py b/aiida/backends/sqlalchemy/migrations/versions/12536798d4d3_trajectory_symbols_to_attribute.py index 2d16a84133..b91636d1eb 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/12536798d4d3_trajectory_symbols_to_attribute.py +++ b/aiida/backends/sqlalchemy/migrations/versions/12536798d4d3_trajectory_symbols_to_attribute.py @@ -25,7 +25,7 @@ from alembic import op from sqlalchemy import Integer, String, cast from sqlalchemy.dialects.postgresql import JSONB, UUID -from sqlalchemy.sql import column, func, select, table, text +from sqlalchemy.sql import column, func, select, table from aiida.backends.sqlalchemy.migrations.utils.utils import load_numpy_array_from_repository @@ -69,20 +69,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - connection = op.get_bind() - - DbNode = table( - 'db_dbnode', - column('id', Integer), - column('uuid', UUID), - column('type', String), - column('attributes', JSONB), - ) - - nodes = connection.execute( - select(DbNode.c.id, - DbNode.c.uuid).where(DbNode.c.type == op.inline_literal('node.data.array.trajectory.TrajectoryData.')) - ).fetchall() - - for pk, _ in nodes: - connection.execute(text(f"""UPDATE db_dbnode SET attributes = attributes #- '{{symbols}}' WHERE id = {pk}""")) + raise NotImplementedError('Downgrade of 12536798d4d3.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/140c971ae0a3_migrate_builtin_calculations.py b/aiida/backends/sqlalchemy/migrations/versions/140c971ae0a3_migrate_builtin_calculations.py index bcfa908ba2..b05ee5141e 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/140c971ae0a3_migrate_builtin_calculations.py +++ b/aiida/backends/sqlalchemy/migrations/versions/140c971ae0a3_migrate_builtin_calculations.py @@ -61,29 +61,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() # pylint: disable=no-member - - statement = text( - """ - UPDATE db_dbnode SET type = 'calculation.job.simpleplugins.arithmetic.add.ArithmeticAddCalculation.' - WHERE type = 'calculation.job.arithmetic.add.ArithmeticAddCalculation.'; - - UPDATE db_dbnode SET type = 'calculation.job.simpleplugins.templatereplacer.TemplatereplacerCalculation.' - WHERE type = 'calculation.job.templatereplacer.TemplatereplacerCalculation.'; - - UPDATE db_dbnode SET process_type = 'aiida.calculations:simpleplugins.arithmetic.add' - WHERE process_type = 'aiida.calculations:arithmetic.add'; - - UPDATE db_dbnode SET process_type = 'aiida.calculations:simpleplugins.templatereplacer' - WHERE process_type = 'aiida.calculations:templatereplacer'; - - UPDATE db_dbnode SET attributes = jsonb_set(attributes, '{"input_plugin"}', '"simpleplugins.arithmetic.add"') - WHERE attributes @> '{"input_plugin": "arithmetic.add"}' - AND type = 'data.code.Code.'; - - UPDATE db_dbnode SET attributes = jsonb_set(attributes, '{"input_plugin"}', '"simpleplugins.templatereplacer"') - WHERE attributes @> '{"input_plugin": "templatereplacer"}' - AND type = 'data.code.Code.'; - """ - ) - conn.execute(statement) + raise NotImplementedError('Downgrade of 140c971ae0a3.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/162b99bca4a2_drop_dbcalcstate.py b/aiida/backends/sqlalchemy/migrations/versions/162b99bca4a2_drop_dbcalcstate.py index 1d0539a20a..75184ec65d 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/162b99bca4a2_drop_dbcalcstate.py +++ b/aiida/backends/sqlalchemy/migrations/versions/162b99bca4a2_drop_dbcalcstate.py @@ -16,8 +16,6 @@ """ from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = '162b99bca4a2' @@ -27,19 +25,10 @@ def upgrade(): + """Migrations for the upgrade.""" op.drop_table('db_dbcalcstate') def downgrade(): - op.create_table( - 'db_dbcalcstate', sa.Column('id', sa.INTEGER(), nullable=False), - sa.Column('dbnode_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('state', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('time', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['dbnode_id'], ['db_dbnode.id'], - name='db_dbcalcstate_dbnode_id_fkey', - ondelete='CASCADE', - initially='DEFERRED', - deferrable=True), sa.PrimaryKeyConstraint('id', name='db_dbcalcstate_pkey'), - sa.UniqueConstraint('dbnode_id', 'state', name='db_dbcalcstate_dbnode_id_state_key') - ) + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 162b99bca4a2.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py b/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py index d3a6f97543..fad8751081 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py +++ b/aiida/backends/sqlalchemy/migrations/versions/1830c8430131_drop_node_columns_nodeversion_public.py @@ -20,7 +20,6 @@ # pylint: disable=invalid-name,no-member,import-error,no-name-in-module from alembic import op -import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '1830c8430131' @@ -30,10 +29,11 @@ def upgrade(): + """Migrations for the upgrade.""" op.drop_column('db_dbnode', 'nodeversion') op.drop_column('db_dbnode', 'public') def downgrade(): - op.add_column('db_dbnode', sa.Column('public', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('db_dbnode', sa.Column('nodeversion', sa.INTEGER(), autoincrement=False, nullable=True)) + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 1830c8430131.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/1b8ed3425af9_remove_legacy_workflows.py b/aiida/backends/sqlalchemy/migrations/versions/1b8ed3425af9_remove_legacy_workflows.py index 65dcd803b3..23b9363e3a 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/1b8ed3425af9_remove_legacy_workflows.py +++ b/aiida/backends/sqlalchemy/migrations/versions/1b8ed3425af9_remove_legacy_workflows.py @@ -7,7 +7,7 @@ # For further information on the license, see the LICENSE.txt file # # For further information please visit http://www.aiida.net # ########################################################################### -# pylint: disable=invalid-name +# pylint: disable=invalid-name,no-member,import-error,no-name-in-module """Remove legacy workflows This is similar to migration django_0032 @@ -17,11 +17,7 @@ Create Date: 2019-04-03 17:11:44.073582 """ -# Remove when https://github.com/PyCQA/pylint/issues/1931 is fixed -# pylint: disable=no-member,import-error,no-name-in-module from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql from aiida.backends.sqlalchemy.migrations.utils.legacy_workflows import export_workflow_data @@ -49,84 +45,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.create_table( - 'db_dbworkflow', - sa.Column( - 'id', - sa.INTEGER(), - server_default=sa.text("nextval('db_dbworkflow_id_seq'::regclass)"), - autoincrement=True, - nullable=False - ), - sa.Column('uuid', postgresql.UUID(), autoincrement=False, nullable=True), - sa.Column('ctime', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('mtime', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('label', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('description', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('nodeversion', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('lastsyncedversion', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('state', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('report', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('module', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('module_class', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('script_path', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('script_md5', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['user_id'], ['db_dbuser.id'], name='db_dbworkflow_user_id_fkey'), - sa.PrimaryKeyConstraint('id', name='db_dbworkflow_pkey'), - sa.UniqueConstraint('uuid', name='db_dbworkflow_uuid_key'), - postgresql_ignore_search_path=False - ) - op.create_index('ix_db_dbworkflow_label', 'db_dbworkflow', ['label'], unique=False) - op.create_table( - 'db_dbworkflowdata', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('time', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('data_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('value_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('json_value', sa.TEXT(), autoincrement=False, nullable=True), - sa.Column('aiida_obj_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['aiida_obj_id'], ['db_dbnode.id'], name='db_dbworkflowdata_aiida_obj_id_fkey'), - sa.ForeignKeyConstraint(['parent_id'], ['db_dbworkflow.id'], name='db_dbworkflowdata_parent_id_fkey'), - sa.PrimaryKeyConstraint('id', name='db_dbworkflowdata_pkey'), - sa.UniqueConstraint('parent_id', 'name', 'data_type', name='db_dbworkflowdata_parent_id_name_data_type_key') - ) - op.create_index('ix_db_dbworkflowdata_parent_id', 'db_dbworkflowdata', ['parent_id'], unique=False) - op.create_index('ix_db_dbworkflowdata_aiida_obj_id', 'db_dbworkflowdata', ['aiida_obj_id'], unique=False) - op.create_table( - 'db_dbworkflowstep', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('name', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('time', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('nextcall', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('state', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['parent_id'], ['db_dbworkflow.id'], name='db_dbworkflowstep_parent_id_fkey'), - sa.ForeignKeyConstraint(['user_id'], ['db_dbuser.id'], name='db_dbworkflowstep_user_id_fkey'), - sa.PrimaryKeyConstraint('id', name='db_dbworkflowstep_pkey'), - sa.UniqueConstraint('parent_id', 'name', name='db_dbworkflowstep_parent_id_name_key') - ) - op.create_table( - 'db_dbworkflowstep_calculations', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('dbworkflowstep_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('dbnode_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['dbnode_id'], ['db_dbnode.id'], name='db_dbworkflowstep_calculations_dbnode_id_fkey'), - sa.ForeignKeyConstraint(['dbworkflowstep_id'], ['db_dbworkflowstep.id'], - name='db_dbworkflowstep_calculations_dbworkflowstep_id_fkey'), - sa.PrimaryKeyConstraint('id', name='db_dbworkflowstep_calculations_pkey'), - sa.UniqueConstraint('dbworkflowstep_id', 'dbnode_id', name='db_dbworkflowstep_calculations_id_dbnode_id_key') - ) - op.create_table( - 'db_dbworkflowstep_sub_workflows', sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('dbworkflowstep_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('dbworkflow_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['dbworkflow_id'], ['db_dbworkflow.id'], - name='db_dbworkflowstep_sub_workflows_dbworkflow_id_fkey'), - sa.ForeignKeyConstraint(['dbworkflowstep_id'], ['db_dbworkflowstep.id'], - name='db_dbworkflowstep_sub_workflows_dbworkflowstep_id_fkey'), - sa.PrimaryKeyConstraint('id', name='db_dbworkflowstep_sub_workflows_pkey'), - sa.UniqueConstraint( - 'dbworkflowstep_id', 'dbworkflow_id', name='db_dbworkflowstep_sub_workflows_id_dbworkflow__key' - ) - ) + raise NotImplementedError('Removal of legacy workflows is not reversible.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/1de112340b16_django_parity_1.py b/aiida/backends/sqlalchemy/migrations/versions/1de112340b16_django_parity_1.py index 97c50d7f73..b2ea6f2791 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/1de112340b16_django_parity_1.py +++ b/aiida/backends/sqlalchemy/migrations/versions/1de112340b16_django_parity_1.py @@ -168,4 +168,4 @@ def upgrade(): # pylint: disable=too-many-statements def downgrade(): """Downgrade database schema.""" - # No need to convert the values back to null + raise NotImplementedError('Downgrade of 1de112340b16.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/1de112340b18_django_parity_3.py b/aiida/backends/sqlalchemy/migrations/versions/1de112340b18_django_parity_3.py index 1abb0a61c5..4b661b5db5 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/1de112340b18_django_parity_3.py +++ b/aiida/backends/sqlalchemy/migrations/versions/1de112340b18_django_parity_3.py @@ -33,3 +33,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 1de112340b18.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/1feaea71bd5a_migrate_repository.py b/aiida/backends/sqlalchemy/migrations/versions/1feaea71bd5a_migrate_repository.py index e8aa29b9d8..d0121864d6 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/1feaea71bd5a_migrate_repository.py +++ b/aiida/backends/sqlalchemy/migrations/versions/1feaea71bd5a_migrate_repository.py @@ -33,3 +33,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Migration of the file repository is not reversible.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/239cea6d2452_provenance_redesign.py b/aiida/backends/sqlalchemy/migrations/versions/239cea6d2452_provenance_redesign.py index cfa35a2efc..48b2c0db9a 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/239cea6d2452_provenance_redesign.py +++ b/aiida/backends/sqlalchemy/migrations/versions/239cea6d2452_provenance_redesign.py @@ -25,7 +25,7 @@ def upgrade(): - """The upgrade migration actions.""" + """Migrations for the upgrade.""" from aiida.backends.sqlalchemy.migrations.utils import provenance_redesign # Migrate calculation nodes by inferring the process type from the type string @@ -109,32 +109,5 @@ def upgrade(): def downgrade(): - """The downgrade migration actions.""" - op.execute( - """ - UPDATE db_dbnode SET type = 'calculation.job.JobCalculation.' - WHERE type = 'node.process.calculation.calcjob.CalcJobNode.'; - - UPDATE db_dbnode SET type = 'calculatison.inline.InlineCalculation.' - WHERE type = 'node.process.calculation.calcfunction.CalcFunctionNode.'; - - UPDATE db_dbnode SET type = 'calculation.function.FunctionCalculation.' - WHERE type = 'node.process.workflow.workfunction.WorkFunctionNode.'; - - UPDATE db_dbnode SET type = 'calculation.work.WorkCalculation.' - WHERE type = 'node.process.workflow.workchain.WorkChainNode.'; - - - UPDATE db_dblink SET type = 'inputlink' - WHERE type = 'input_call' OR type = 'input_work'; - - UPDATE db_dblink SET type = 'calllink' - WHERE type = 'call_call' OR type = 'call_work'; - - UPDATE db_dblink SET type = 'createlink' - WHERE type = 'create'; - - UPDATE db_dblink SET type = 'returnlink' - WHERE type = 'return'; - """ - ) + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 239cea6d2452.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/26d561acd560_data_migration_legacy_job_calculations.py b/aiida/backends/sqlalchemy/migrations/versions/26d561acd560_data_migration_legacy_job_calculations.py index 93910120c8..c5e36bbdd9 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/26d561acd560_data_migration_legacy_job_calculations.py +++ b/aiida/backends/sqlalchemy/migrations/versions/26d561acd560_data_migration_legacy_job_calculations.py @@ -112,3 +112,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 26d561acd560.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/34a831f4286d_entry_point_core_prefix.py b/aiida/backends/sqlalchemy/migrations/versions/34a831f4286d_entry_point_core_prefix.py index 4d5492e83e..bb9d27d632 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/34a831f4286d_entry_point_core_prefix.py +++ b/aiida/backends/sqlalchemy/migrations/versions/34a831f4286d_entry_point_core_prefix.py @@ -75,3 +75,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 34a831f4286d.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/35d4ee9a1b0e_code_hidden_attr_to_extra.py b/aiida/backends/sqlalchemy/migrations/versions/35d4ee9a1b0e_code_hidden_attr_to_extra.py index 8d417a4ffc..8af5134df9 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/35d4ee9a1b0e_code_hidden_attr_to_extra.py +++ b/aiida/backends/sqlalchemy/migrations/versions/35d4ee9a1b0e_code_hidden_attr_to_extra.py @@ -54,26 +54,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - - # Set hidden=True in attributes if the extras contain hidden=True - statement = text( - """ - UPDATE db_dbnode SET attributes = jsonb_set(attributes, '{"hidden"}', to_jsonb(True)) - WHERE type = 'code.Code.' AND extras @> '{"hidden": true}' - """ - ) - conn.execute(statement) - - # Set hidden=False in attributes if the extras contain hidden=False - statement = text( - """ - UPDATE db_dbnode SET attributes = jsonb_set(attributes, '{"hidden"}', to_jsonb(False)) - WHERE type = 'code.Code.' AND extras @> '{"hidden": false}' - """ - ) - conn.execute(statement) - - # Delete the hidden key from the extras - statement = text("""UPDATE db_dbnode SET extras = extras-'hidden' WHERE type = 'code.Code.'""") - conn.execute(statement) + raise NotImplementedError('Downgrade of 35d4ee9a1b0e.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/375c2db70663_dblog_uuid_uniqueness_constraint.py b/aiida/backends/sqlalchemy/migrations/versions/375c2db70663_dblog_uuid_uniqueness_constraint.py index 73ccd2b232..ee8f18e24b 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/375c2db70663_dblog_uuid_uniqueness_constraint.py +++ b/aiida/backends/sqlalchemy/migrations/versions/375c2db70663_dblog_uuid_uniqueness_constraint.py @@ -27,10 +27,10 @@ def upgrade(): - """Add unique key constraint to the UUID column.""" + """Migrations for the upgrade.""" op.create_unique_constraint('db_dblog_uuid_key', 'db_dblog', ['uuid']) def downgrade(): - """Remove unique key constraint to the UUID column.""" + """Migrations for the downgrade.""" op.drop_constraint('db_dblog_uuid_key', 'db_dblog') diff --git a/aiida/backends/sqlalchemy/migrations/versions/37f3d4882837_make_all_uuid_columns_unique.py b/aiida/backends/sqlalchemy/migrations/versions/37f3d4882837_make_all_uuid_columns_unique.py index d444717e84..9a9a4a56af 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/37f3d4882837_make_all_uuid_columns_unique.py +++ b/aiida/backends/sqlalchemy/migrations/versions/37f3d4882837_make_all_uuid_columns_unique.py @@ -41,5 +41,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - for table in tables: - op.drop_constraint(f'{table}_uuid_key', table) + raise NotImplementedError('Downgrade of 37f3d4882837.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/535039300e4a_computer_name_to_label.py b/aiida/backends/sqlalchemy/migrations/versions/535039300e4a_computer_name_to_label.py index 64753bc137..7eba581d70 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/535039300e4a_computer_name_to_label.py +++ b/aiida/backends/sqlalchemy/migrations/versions/535039300e4a_computer_name_to_label.py @@ -25,6 +25,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_constraint('db_dbcomputer_label_key', 'db_dbcomputer') - op.alter_column('db_dbcomputer', 'label', new_column_name='name') # pylint: disable=no-member - op.create_unique_constraint('db_dbcomputer_name_key', 'db_dbcomputer', ['name']) + raise NotImplementedError('Downgrade of 535039300e4a.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/59edaf8a8b79_adding_indexes_and_constraints_to_the_.py b/aiida/backends/sqlalchemy/migrations/versions/59edaf8a8b79_adding_indexes_and_constraints_to_the_.py index 9f47898db8..b1233583a0 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/59edaf8a8b79_adding_indexes_and_constraints_to_the_.py +++ b/aiida/backends/sqlalchemy/migrations/versions/59edaf8a8b79_adding_indexes_and_constraints_to_the_.py @@ -43,11 +43,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_index('db_dbgroup_dbnodes_dbnode_id_idx', 'db_dbgroup_dbnodes') - op.drop_index('db_dbgroup_dbnodes_dbgroup_id_idx', 'db_dbgroup_dbnodes') - op.drop_constraint('db_dbgroup_dbnodes_dbgroup_id_dbnode_id_key', 'db_dbgroup_dbnodes') - # Creating the constraint uix_dbnode_id_dbgroup_id that migration - # 7a6587e16f4c would add - op.create_unique_constraint( - 'db_dbgroup_dbnodes_dbgroup_id_dbnode_id_key', 'db_dbgroup_dbnodes', ['dbgroup_id', 'dbnode_id'] - ) + raise NotImplementedError('Downgrade of 59edaf8a8b79.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/61fc0913fae9_remove_node_prefix.py b/aiida/backends/sqlalchemy/migrations/versions/61fc0913fae9_remove_node_prefix.py index 857a6acb58..b3bed0c1ad 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/61fc0913fae9_remove_node_prefix.py +++ b/aiida/backends/sqlalchemy/migrations/versions/61fc0913fae9_remove_node_prefix.py @@ -52,17 +52,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - - statement = text( - r""" - UPDATE db_dbnode - SET type = regexp_replace(type, '^data.', 'node.data.') - WHERE type LIKE 'data.%'; - - UPDATE db_dbnode - SET type = regexp_replace(type, '^process.', 'node.process.') - WHERE type LIKE 'process.%'; - """ - ) - conn.execute(statement) + raise NotImplementedError('Downgrade of 61fc0913fae9.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/6a5c2ea1439d_move_data_within_node_module.py b/aiida/backends/sqlalchemy/migrations/versions/6a5c2ea1439d_move_data_within_node_module.py index 48bfdf9131..82243643af 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/6a5c2ea1439d_move_data_within_node_module.py +++ b/aiida/backends/sqlalchemy/migrations/versions/6a5c2ea1439d_move_data_within_node_module.py @@ -45,13 +45,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - - statement = text( - r""" - UPDATE db_dbnode - SET type = regexp_replace(type, '^node.data.', 'data.') - WHERE type LIKE 'node.data.%' - """ - ) - conn.execute(statement) + raise NotImplementedError('Downgrade of 6a5c2ea1439d.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/70c7d732f1b2_delete_dbpath.py b/aiida/backends/sqlalchemy/migrations/versions/70c7d732f1b2_delete_dbpath.py index b037edf3f7..590ea1c531 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/70c7d732f1b2_delete_dbpath.py +++ b/aiida/backends/sqlalchemy/migrations/versions/70c7d732f1b2_delete_dbpath.py @@ -17,9 +17,6 @@ """ from alembic import op import sqlalchemy as sa -from sqlalchemy.orm.session import Session - -from aiida.backends.sqlalchemy.utils import install_tc # revision identifiers, used by Alembic. revision = '70c7d732f1b2' @@ -38,25 +35,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.create_table( - 'db_dbpath', sa.Column('id', sa.INTEGER(), nullable=False), - sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('child_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('depth', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('entry_edge_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('direct_edge_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('exit_edge_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['child_id'], ['db_dbnode.id'], - name='db_dbpath_child_id_fkey', - initially='DEFERRED', - deferrable=True), - sa.ForeignKeyConstraint(['parent_id'], ['db_dbnode.id'], - name='db_dbpath_parent_id_fkey', - initially='DEFERRED', - deferrable=True), sa.PrimaryKeyConstraint('id', name='db_dbpath_pkey') - ) - # I get the session using the alembic connection - # (Keep in mind that alembic uses the AiiDA SQLA - # session) - session = Session(bind=op.get_bind()) - install_tc(session) + raise NotImplementedError('Downgrade of 70c7d732f1b2.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/7b38a9e783e7_seal_unsealed_processes.py b/aiida/backends/sqlalchemy/migrations/versions/7b38a9e783e7_seal_unsealed_processes.py index a6d3d5858a..6ceef2552c 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/7b38a9e783e7_seal_unsealed_processes.py +++ b/aiida/backends/sqlalchemy/migrations/versions/7b38a9e783e7_seal_unsealed_processes.py @@ -63,3 +63,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 7b38a9e783e7.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/7ca08c391c49_calc_job_option_attribute_keys.py b/aiida/backends/sqlalchemy/migrations/versions/7ca08c391c49_calc_job_option_attribute_keys.py index 953111f23e..26819ca508 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/7ca08c391c49_calc_job_option_attribute_keys.py +++ b/aiida/backends/sqlalchemy/migrations/versions/7ca08c391c49_calc_job_option_attribute_keys.py @@ -95,4 +95,5 @@ def upgrade(): def downgrade(): - pass + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 7ca08c391c49.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/89176227b25_add_indexes_to_dbworkflowdata_table.py b/aiida/backends/sqlalchemy/migrations/versions/89176227b25_add_indexes_to_dbworkflowdata_table.py index f3f8087837..0cf4ab55d2 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/89176227b25_add_indexes_to_dbworkflowdata_table.py +++ b/aiida/backends/sqlalchemy/migrations/versions/89176227b25_add_indexes_to_dbworkflowdata_table.py @@ -25,10 +25,11 @@ def upgrade(): + """Migrations for the upgrade.""" op.create_index('ix_db_dbworkflowdata_aiida_obj_id', 'db_dbworkflowdata', ['aiida_obj_id']) op.create_index('ix_db_dbworkflowdata_parent_id', 'db_dbworkflowdata', ['parent_id']) def downgrade(): - op.drop_index('ix_db_dbworkflowdata_aiida_obj_id', 'db_dbworkflowdata') - op.drop_index('ix_db_dbworkflowdata_parent_id', 'db_dbworkflowdata') + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 89176227b25.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/91b573400be5_prepare_schema_reset.py b/aiida/backends/sqlalchemy/migrations/versions/91b573400be5_prepare_schema_reset.py index de009cabab..b48f3429e5 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/91b573400be5_prepare_schema_reset.py +++ b/aiida/backends/sqlalchemy/migrations/versions/91b573400be5_prepare_schema_reset.py @@ -52,3 +52,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of 91b573400be5.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/a514d673c163_drop_dblock.py b/aiida/backends/sqlalchemy/migrations/versions/a514d673c163_drop_dblock.py index f539716b45..2a3d6e4f57 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/a514d673c163_drop_dblock.py +++ b/aiida/backends/sqlalchemy/migrations/versions/a514d673c163_drop_dblock.py @@ -16,8 +16,6 @@ """ from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = 'a514d673c163' @@ -27,14 +25,10 @@ def upgrade(): + """Migrations for the upgrade.""" op.drop_table('db_dblock') def downgrade(): - op.create_table( - 'db_dblock', sa.Column('key', sa.VARCHAR(length=255), autoincrement=False, nullable=False), - sa.Column('creation', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True), - sa.Column('timeout', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('owner', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('key', name='db_dblock_pkey') - ) + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of a514d673c163.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/a6048f0ffca8_update_linktypes.py b/aiida/backends/sqlalchemy/migrations/versions/a6048f0ffca8_update_linktypes.py index 440d41cf20..0b55342c49 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/a6048f0ffca8_update_linktypes.py +++ b/aiida/backends/sqlalchemy/migrations/versions/a6048f0ffca8_update_linktypes.py @@ -151,4 +151,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - print('There is no downgrade for the link types') + raise NotImplementedError('Downgrade of a6048f0ffca8.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/b8b23ddefad4_dbgroup_name_to_label_type_to_type_string.py b/aiida/backends/sqlalchemy/migrations/versions/b8b23ddefad4_dbgroup_name_to_label_type_to_type_string.py index 48ae39eb1d..b2fc72b083 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/b8b23ddefad4_dbgroup_name_to_label_type_to_type_string.py +++ b/aiida/backends/sqlalchemy/migrations/versions/b8b23ddefad4_dbgroup_name_to_label_type_to_type_string.py @@ -44,16 +44,4 @@ def upgrade(): def downgrade(): """The downgrade migration actions.""" - # dropping - op.drop_constraint('db_dbgroup_label_type_string_key', 'db_dbgroup') - op.drop_index('ix_db_dbgroup_label', 'db_dbgroup') - op.drop_index('ix_db_dbgroup_type_string', 'db_dbgroup') - - # renaming - op.alter_column('db_dbgroup', 'label', new_column_name='name') - op.alter_column('db_dbgroup', 'type_string', new_column_name='type') - - # creating - op.create_unique_constraint('db_dbgroup_name_type_key', 'db_dbgroup', ['name', 'type']) - op.create_index('ix_db_dbgroup_name', 'db_dbgroup', ['name']) - op.create_index('ix_db_dbgroup_type', 'db_dbgroup', ['type']) + raise NotImplementedError('Downgrade of b8b23ddefad4.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/bf591f31dd12_dbgroup_type_string.py b/aiida/backends/sqlalchemy/migrations/versions/bf591f31dd12_dbgroup_type_string.py index 6d71cd55f6..6f3cd63df1 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/bf591f31dd12_dbgroup_type_string.py +++ b/aiida/backends/sqlalchemy/migrations/versions/bf591f31dd12_dbgroup_type_string.py @@ -26,13 +26,6 @@ """UPDATE db_dbgroup SET type_string = 'core.auto' WHERE type_string = 'auto.run';""", ] -reverse_sql = [ - """UPDATE db_dbgroup SET type_string = 'user' WHERE type_string = 'core';""", - """UPDATE db_dbgroup SET type_string = 'data.upf' WHERE type_string = 'core.upf';""", - """UPDATE db_dbgroup SET type_string = 'auto.import' WHERE type_string = 'core.import';""", - """UPDATE db_dbgroup SET type_string = 'auto.run' WHERE type_string = 'core.auto';""", -] - # revision identifiers, used by Alembic. revision = 'bf591f31dd12' down_revision = '118349c10896' @@ -49,6 +42,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - statement = text('\n'.join(reverse_sql)) - conn.execute(statement) + raise NotImplementedError('Downgrade of bf591f31dd12.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/ce56d84bcc35_delete_trajectory_symbols_array.py b/aiida/backends/sqlalchemy/migrations/versions/ce56d84bcc35_delete_trajectory_symbols_array.py index 1e55909815..cc8f3c10ef 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/ce56d84bcc35_delete_trajectory_symbols_array.py +++ b/aiida/backends/sqlalchemy/migrations/versions/ce56d84bcc35_delete_trajectory_symbols_array.py @@ -18,10 +18,9 @@ """ from alembic import op -import numpy -from sqlalchemy import Integer, String, cast +from sqlalchemy import Integer, String from sqlalchemy.dialects.postgresql import JSONB, UUID -from sqlalchemy.sql import column, func, select, table, text +from sqlalchemy.sql import column, select, table, text from aiida.backends.sqlalchemy.migrations.utils import utils @@ -60,30 +59,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - connection = op.get_bind() - profile = connection, op.get_context().opts['aiida_profile'] - repo_path = profile.repository_path - - DbNode = table( - 'db_dbnode', - column('id', Integer), - column('uuid', UUID), - column('type', String), - column('attributes', JSONB), - ) - - nodes = connection.execute( - select(DbNode.c.id, - DbNode.c.uuid).where(DbNode.c.type == op.inline_literal('node.data.array.trajectory.TrajectoryData.')) - ).fetchall() - - for pk, uuid in nodes: - attributes = connection.execute(select(DbNode.c.attributes).where(DbNode.c.id == pk)).fetchone() - symbols = numpy.array(attributes['symbols']) - utils.store_numpy_array_in_repository(repo_path, uuid, 'symbols', symbols) - key = op.inline_literal('{"array|symbols"}') - connection.execute( - DbNode.update().where(DbNode.c.id == pk).values( - attributes=func.jsonb_set(DbNode.c.attributes, key, cast(list(symbols.shape), JSONB)) - ) - ) + raise NotImplementedError('Downgrade of ce56d84bcc35.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/d254fdfed416_rename_parameter_data_to_dict.py b/aiida/backends/sqlalchemy/migrations/versions/d254fdfed416_rename_parameter_data_to_dict.py index 7b766c35b3..424e424718 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/d254fdfed416_rename_parameter_data_to_dict.py +++ b/aiida/backends/sqlalchemy/migrations/versions/d254fdfed416_rename_parameter_data_to_dict.py @@ -41,11 +41,9 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - statement = text( r""" UPDATE db_dbnode SET type = 'data.parameter.ParameterData.' WHERE type = 'data.dict.Dict.'; """ ) - conn.execute(statement) + op.get_bind().execute(statement) diff --git a/aiida/backends/sqlalchemy/migrations/versions/de2eaf6978b4_simplify_user_model.py b/aiida/backends/sqlalchemy/migrations/versions/de2eaf6978b4_simplify_user_model.py index 5ece380611..d4470057ce 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/de2eaf6978b4_simplify_user_model.py +++ b/aiida/backends/sqlalchemy/migrations/versions/de2eaf6978b4_simplify_user_model.py @@ -19,10 +19,7 @@ Create Date: 2019-05-28 11:15:33.242602 """ - from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revision = 'de2eaf6978b4' @@ -43,13 +40,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.add_column( - 'db_dbuser', sa.Column('date_joined', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True) - ) - op.add_column('db_dbuser', sa.Column('password', sa.VARCHAR(length=128), autoincrement=False, nullable=True)) - op.add_column( - 'db_dbuser', sa.Column('last_login', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True) - ) - op.add_column('db_dbuser', sa.Column('is_staff', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('db_dbuser', sa.Column('is_superuser', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('db_dbuser', sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True)) + raise NotImplementedError('Downgrade of de2eaf6978b4.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0002_db_state_change.py b/aiida/backends/sqlalchemy/migrations/versions/django_0002_db_state_change.py index dd5b3d939a..928d0cc4e7 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0002_db_state_change.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0002_db_state_change.py @@ -44,3 +44,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0002.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0003_add_link_type.py b/aiida/backends/sqlalchemy/migrations/versions/django_0003_add_link_type.py index ac64ec9da8..a659e4f308 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0003_add_link_type.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0003_add_link_type.py @@ -44,8 +44,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_index('db_dblink_type_229f212b_like', table_name='db_dblink') - op.drop_index('db_dblink_type_229f212b', table_name='db_dblink') - op.drop_column('db_dblink', 'type') - op.create_unique_constraint('db_dblink_input_id_output_id_fbe99cb5_uniq', 'db_dblink', ['input_id', 'output_id']) - op.create_unique_constraint('db_dblink_output_id_label_00bdb9c7_uniq', 'db_dblink', ['output_id', 'label']) + raise NotImplementedError('Downgrade of django_0003.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0004_add_daemon_and_uuid_indices.py b/aiida/backends/sqlalchemy/migrations/versions/django_0004_add_daemon_and_uuid_indices.py index 6f140ea8ba..94ab927b17 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0004_add_daemon_and_uuid_indices.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0004_add_daemon_and_uuid_indices.py @@ -43,5 +43,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_index('tval_idx_for_daemon', table_name='db_dbattribute') - op.drop_index('db_dbnode_uuid_62e0bf98', table_name='db_dbnode') + raise NotImplementedError('Downgrade of django_0004.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0005_add_cmtime_indices.py b/aiida/backends/sqlalchemy/migrations/versions/django_0005_add_cmtime_indices.py index 97880eef49..13eef22067 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0005_add_cmtime_indices.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0005_add_cmtime_indices.py @@ -30,5 +30,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_index('db_dbnode_ctime_71626ef5', table_name='db_dbnode') - op.drop_index('db_dbnode_mtime_0554ea3d', table_name='db_dbnode') + raise NotImplementedError('Downgrade of django_0005.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0006_delete_dbpath.py b/aiida/backends/sqlalchemy/migrations/versions/django_0006_delete_dbpath.py index 4eb8347cad..718ac3fb49 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0006_delete_dbpath.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0006_delete_dbpath.py @@ -15,7 +15,6 @@ """ from alembic import op -import sqlalchemy as sa revision = 'django_0006' down_revision = 'django_0005' @@ -38,30 +37,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.create_table( - 'db_dbpath', - sa.Column('id', sa.INTEGER(), nullable=False), - sa.PrimaryKeyConstraint('id', name='db_dbpath_pkey'), - sa.Column('parent_id', sa.INTEGER(), nullable=False), - sa.Column('child_id', sa.INTEGER(), nullable=False), - sa.Column('depth', sa.INTEGER(), nullable=False), - sa.Column('entry_edge_id', sa.INTEGER(), nullable=True), - sa.Column('direct_edge_id', sa.INTEGER(), nullable=True), - sa.Column('exit_edge_id', sa.INTEGER(), nullable=True), - sa.Index('db_dbpath_child_id_d8228636', 'child_id'), - sa.Index('db_dbpath_parent_id_3b82d6c8', 'parent_id'), - sa.ForeignKeyConstraint( - ['child_id'], - ['db_dbnode.id'], - name='db_dbpath_child_id_d8228636_fk_db_dbnode_id', - initially='DEFERRED', - deferrable=True, - ), - sa.ForeignKeyConstraint( - ['parent_id'], - ['db_dbnode.id'], - name='db_dbpath_parent_id_3b82d6c8_fk_db_dbnode_id', - initially='DEFERRED', - deferrable=True, - ), - ) + raise NotImplementedError('Downgrade of django_0006.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0007_update_linktypes.py b/aiida/backends/sqlalchemy/migrations/versions/django_0007_update_linktypes.py index 25bac6218b..ec9532990a 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0007_update_linktypes.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0007_update_linktypes.py @@ -141,3 +141,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0007.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0008_code_hidden_to_extra.py b/aiida/backends/sqlalchemy/migrations/versions/django_0008_code_hidden_to_extra.py index b508cb8b9f..f854ee393a 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0008_code_hidden_to_extra.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0008_code_hidden_to_extra.py @@ -56,3 +56,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0008.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0010_process_type.py b/aiida/backends/sqlalchemy/migrations/versions/django_0010_process_type.py index dd1f411185..145693aa09 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0010_process_type.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0010_process_type.py @@ -38,6 +38,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_index('db_dbnode_process_type_df7298d0_like', table_name='db_dbnode') - op.drop_index('db_dbnode_process_type_df7298d0', table_name='db_dbnode') - op.drop_column('db_dbnode', 'process_type') + raise NotImplementedError('Downgrade of django_0010.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0011_delete_kombu_tables.py b/aiida/backends/sqlalchemy/migrations/versions/django_0011_delete_kombu_tables.py index 7794359286..6c79366873 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0011_delete_kombu_tables.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0011_delete_kombu_tables.py @@ -41,4 +41,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - print('There is no downgrade for the deletion of the kombu tables and the daemon timestamps') + raise NotImplementedError('Deletion of the kombu tables is not reversible.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0012_drop_dblock.py b/aiida/backends/sqlalchemy/migrations/versions/django_0012_drop_dblock.py index b97d686b3d..30760711a0 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0012_drop_dblock.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0012_drop_dblock.py @@ -15,8 +15,6 @@ """ from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql revision = 'django_0012' down_revision = 'django_0011' @@ -31,17 +29,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.create_table( - 'db_dblock', - sa.Column('key', sa.VARCHAR(length=255), nullable=False), - sa.PrimaryKeyConstraint('key', name='db_dblock_pkey'), - sa.Column('creation', postgresql.TIMESTAMP(timezone=True), nullable=False), - sa.Column('timeout', sa.INTEGER(), nullable=False), - sa.Column('owner', sa.VARCHAR(length=255), nullable=False), - sa.Index( - 'db_dblock_key_048c6767_like', - 'key', - postgresql_using='btree', - postgresql_ops={'key': 'varchar_pattern_ops'}, - ), - ) + raise NotImplementedError('Downgrade of django_0012.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0013_django_1_8.py b/aiida/backends/sqlalchemy/migrations/versions/django_0013_django_1_8.py index 1d957a66d3..76245e3e2f 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0013_django_1_8.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0013_django_1_8.py @@ -47,3 +47,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0013.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0014_add_node_uuid_unique_constraint.py b/aiida/backends/sqlalchemy/migrations/versions/django_0014_add_node_uuid_unique_constraint.py index 02a889aa3d..5255845333 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0014_add_node_uuid_unique_constraint.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0014_add_node_uuid_unique_constraint.py @@ -32,5 +32,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_constraint('db_dbnode_uuid_62e0bf98_uniq', 'db_dbnode', type_='unique') - op.create_index('db_dbnode_uuid_62e0bf98', 'db_dbnode', ['uuid']) + raise NotImplementedError('Downgrade of django_0014.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0017_drop_dbcalcstate.py b/aiida/backends/sqlalchemy/migrations/versions/django_0017_drop_dbcalcstate.py index 8a08b2ef2c..3f9e79a43b 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0017_drop_dbcalcstate.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0017_drop_dbcalcstate.py @@ -15,8 +15,6 @@ """ from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql revision = 'django_0017' down_revision = 'django_0016' @@ -31,27 +29,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.create_table( - 'db_dbcalcstate', - sa.Column('id', sa.INTEGER(), nullable=False), - sa.PrimaryKeyConstraint('id', name='db_dbcalcstate_pkey'), - sa.Column('dbnode_id', sa.INTEGER(), nullable=False), - sa.Column('state', sa.VARCHAR(length=25), nullable=False), - sa.Column('time', postgresql.TIMESTAMP(timezone=True), nullable=False), - sa.UniqueConstraint('dbnode_id', 'state', name='db_dbcalcstate_dbnode_id_state_b4a14db3_uniq'), - sa.Index('db_dbcalcstate_dbnode_id_f217a84c', 'dbnode_id'), - sa.Index('db_dbcalcstate_state_0bf54584', 'state'), - sa.Index( - 'db_dbcalcstate_state_0bf54584_like', - 'state', - postgresql_using='btree', - postgresql_ops={'state': 'varchar_pattern_ops'}, - ), - sa.ForeignKeyConstraint( - ['dbnode_id'], - ['db_dbnode.id'], - name='db_dbcalcstate_dbnode_id_f217a84c_fk_db_dbnode_id', - deferrable=True, - initially='DEFERRED', - ), - ) + raise NotImplementedError('Downgrade of django_0017.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0018_django_1_11.py b/aiida/backends/sqlalchemy/migrations/versions/django_0018_django_1_11.py index a4a2371efc..d2701e54d5 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0018_django_1_11.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0018_django_1_11.py @@ -63,28 +63,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_index('db_dbuser_email_30150b7e_like', table_name='db_dbuser') - op.drop_constraint('db_dbuser_email_30150b7e_uniq', 'db_dbuser', type_='unique') - for table, unique in ( - ('db_dbworkflow', 'db_dbworkflow_uuid_08947ee2_uniq'), - ('db_dbnode', None), - ('db_dbgroup', 'db_dbgroup_uuid_af896177_uniq'), - ('db_dbcomputer', 'db_dbcomputer_uuid_f35defa6_uniq'), - ('db_dbcomment', 'db_dbcomment_uuid_49bac08c_uniq'), - ): - op.alter_column( - table, - 'uuid', - existing_type=postgresql.UUID(as_uuid=True), - type_=sa.VARCHAR(length=36), - nullable=False, - postgresql_using='uuid::text' - ) - if unique: - op.drop_constraint(unique, table, type_='unique') - op.create_index( - 'db_dbnode_uuid_62e0bf98_like', - 'db_dbnode', ['uuid'], - postgresql_using='btree', - postgresql_ops={'uuid': 'varchar_pattern_ops'} - ) + raise NotImplementedError('Downgrade of django_0018.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0019_migrate_builtin_calculations.py b/aiida/backends/sqlalchemy/migrations/versions/django_0019_migrate_builtin_calculations.py index 5a01b1d9db..615ea327bb 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0019_migrate_builtin_calculations.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0019_migrate_builtin_calculations.py @@ -58,30 +58,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.execute( - """ - UPDATE db_dbnode SET type = 'calculation.job.simpleplugins.arithmetic.add.ArithmeticAddCalculation.' - WHERE type = 'calculation.job.arithmetic.add.ArithmeticAddCalculation.'; - - UPDATE db_dbnode SET type = 'calculation.job.simpleplugins.templatereplacer.TemplatereplacerCalculation.' - WHERE type = 'calculation.job.templatereplacer.TemplatereplacerCalculation.'; - - UPDATE db_dbnode SET process_type = 'aiida.calculations:simpleplugins.arithmetic.add' - WHERE process_type = 'aiida.calculations:arithmetic.add'; - - UPDATE db_dbnode SET process_type = 'aiida.calculations:simpleplugins.templatereplacer' - WHERE process_type = 'aiida.calculations:templatereplacer'; - - UPDATE db_dbattribute AS a SET tval = 'simpleplugins.arithmetic.add' - FROM db_dbnode AS n WHERE a.dbnode_id = n.id - AND a.key = 'input_plugin' - AND a.tval = 'arithmetic.add' - AND n.type = 'data.code.Code.'; - - UPDATE db_dbattribute AS a SET tval = 'simpleplugins.templatereplacer' - FROM db_dbnode AS n WHERE a.dbnode_id = n.id - AND a.key = 'input_plugin' - AND a.tval = 'templatereplacer' - AND n.type = 'data.code.Code.'; - """ - ) + raise NotImplementedError('Downgrade of django_0019.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0020_provenance_redesign.py b/aiida/backends/sqlalchemy/migrations/versions/django_0020_provenance_redesign.py index 312895bd5b..12b152b0fe 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0020_provenance_redesign.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0020_provenance_redesign.py @@ -122,31 +122,4 @@ def downgrade(): # migration this is changed to always be `node.process.calculation.calcjob.CalcJobNode.`. # In the reverse operation, this can then only be reset to `calculation.job.JobCalculation.` # but the information on the exact subclass is lost. - op.execute( - """ - UPDATE db_dbnode SET type = 'calculation.job.JobCalculation.' - WHERE type = 'node.process.calculation.calcjob.CalcJobNode.'; - - UPDATE db_dbnode SET type = 'calculatison.inline.InlineCalculation.' - WHERE type = 'node.process.calculation.calcfunction.CalcFunctionNode.'; - - UPDATE db_dbnode SET type = 'calculation.function.FunctionCalculation.' - WHERE type = 'node.process.workflow.workfunction.WorkFunctionNode.'; - - UPDATE db_dbnode SET type = 'calculation.work.WorkCalculation.' - WHERE type = 'node.process.workflow.workchain.WorkChainNode.'; - - - UPDATE db_dblink SET type = 'inputlink' - WHERE type = 'input_call' OR type = 'input_work'; - - UPDATE db_dblink SET type = 'calllink' - WHERE type = 'call_call' OR type = 'call_work'; - - UPDATE db_dblink SET type = 'createlink' - WHERE type = 'create'; - - UPDATE db_dblink SET type = 'returnlink' - WHERE type = 'return'; - """ - ) + raise NotImplementedError('Downgrade of django_0020.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0021_dbgroup_name_to_label_type_to_type_string.py b/aiida/backends/sqlalchemy/migrations/versions/django_0021_dbgroup_name_to_label_type_to_type_string.py index d990a6b501..8d9cb67a92 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0021_dbgroup_name_to_label_type_to_type_string.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0021_dbgroup_name_to_label_type_to_type_string.py @@ -61,32 +61,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - # drop new constraint and indexes - op.drop_constraint('db_dbgroup_name_type_12656f33_uniq', 'db_dbgroup') - op.drop_index('db_dbgroup_name_66c75272', 'db_dbgroup') - op.drop_index('db_dbgroup_name_66c75272_like', 'db_dbgroup') - op.drop_index('db_dbgroup_type_23b2a748', 'db_dbgroup') - op.drop_index('db_dbgroup_type_23b2a748_like', 'db_dbgroup') - - # renaming - op.alter_column('db_dbgroup', 'name', new_column_name='label') - op.alter_column('db_dbgroup', 'type', new_column_name='type_string') - - # create old constraint and indexes - op.create_unique_constraint('db_dbgroup_name_type_12656f33_uniq', 'db_dbgroup', ['name', 'type']) - op.create_index('db_dbgroup_name_66c75272', 'db_dbgroup', ['name']) - op.create_index( - 'db_dbgroup_name_66c75272_like', - 'db_dbgroup', - ['name'], - postgresql_using='btree', - postgresql_ops={'name': 'varchar_pattern_ops'}, - ) - op.create_index('db_dbgroup_type_23b2a748', 'db_dbgroup', ['type']) - op.create_index( - 'db_dbgroup_type_23b2a748_like', - 'db_dbgroup', - ['type'], - postgresql_using='btree', - postgresql_ops={'type': 'varchar_pattern_ops'}, - ) + raise NotImplementedError('Downgrade of django_0021.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0022_dbgroup_type_string_change_content.py b/aiida/backends/sqlalchemy/migrations/versions/django_0022_dbgroup_type_string_change_content.py index 282c602a9a..6542123fa9 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0022_dbgroup_type_string_change_content.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0022_dbgroup_type_string_change_content.py @@ -30,13 +30,6 @@ """UPDATE db_dbgroup SET type_string = 'auto.run' WHERE type_string = 'autogroup.run';""", ] -reverse_sql = [ - """UPDATE db_dbgroup SET type_string = '' WHERE type_string = 'user';""", - """UPDATE db_dbgroup SET type_string = 'data.upf.family' WHERE type_string = 'data.upf';""", - """UPDATE db_dbgroup SET type_string = 'aiida.import' WHERE type_string = 'auto.import';""", - """UPDATE db_dbgroup SET type_string = 'autogroup.run' WHERE type_string = 'auto.run';""", -] - def upgrade(): """Migrations for the upgrade.""" @@ -45,4 +38,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.execute('\n'.join(reverse_sql)) + raise NotImplementedError('Downgrade of django_0022.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0023_calc_job_option_attribute_keys.py b/aiida/backends/sqlalchemy/migrations/versions/django_0023_calc_job_option_attribute_keys.py index bfdada0268..d7f3a862b5 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0023_calc_job_option_attribute_keys.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0023_calc_job_option_attribute_keys.py @@ -85,48 +85,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.execute( - r""" - UPDATE db_dbattribute AS attribute - SET key = regexp_replace(attribute.key, '^environment_variables', 'custom_environment_variables') - FROM db_dbnode AS node - WHERE - ( - attribute.key = 'environment_variables' OR - attribute.key LIKE 'environment\_variables.%' - ) AND - node.type = 'node.process.calculation.calcjob.CalcJobNode.' AND - node.id = attribute.dbnode_id; - -- environment_variables -> custom_environment_variables - - UPDATE db_dbattribute AS attribute - SET key = regexp_replace(attribute.key, '^resources', 'jobresource_params') - FROM db_dbnode AS node - WHERE - ( - attribute.key = 'resources' OR - attribute.key LIKE 'resources.%' - ) AND - node.type = 'node.process.calculation.calcjob.CalcJobNode.' AND - node.id = attribute.dbnode_id; - -- resources -> jobresource_params - - UPDATE db_dbattribute AS attribute - SET key = regexp_replace(attribute.key, '^process_label', '_process_label') - FROM db_dbnode AS node - WHERE - attribute.key = 'process_label' AND - node.type LIKE 'node.process.%' AND - node.id = attribute.dbnode_id; - -- process_label -> _process_label - - UPDATE db_dbattribute AS attribute - SET key = regexp_replace(attribute.key, '^parser_name', 'parser') - FROM db_dbnode AS node - WHERE - attribute.key = 'parser_name' AND - node.type = 'node.process.calculation.calcjob.CalcJobNode.' AND - node.id = attribute.dbnode_id; - -- parser_name -> parser - """ - ) + raise NotImplementedError('Downgrade of django_0023.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0024a_dblog_update.py b/aiida/backends/sqlalchemy/migrations/versions/django_0024a_dblog_update.py index 04778affd6..14b5fac79f 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0024a_dblog_update.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0024a_dblog_update.py @@ -89,3 +89,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0024a.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0024b_dblog_update.py b/aiida/backends/sqlalchemy/migrations/versions/django_0024b_dblog_update.py index 3da2439027..042e601816 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0024b_dblog_update.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0024b_dblog_update.py @@ -31,4 +31,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_constraint('db_dblog_uuid_9cf77df3_uniq', 'db_dblog', type_='unique') + raise NotImplementedError('Downgrade of django_0024.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0025_move_data_within_node_module.py b/aiida/backends/sqlalchemy/migrations/versions/django_0025_move_data_within_node_module.py index f0b35c9429..94b6acc4fb 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0025_move_data_within_node_module.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0025_move_data_within_node_module.py @@ -42,13 +42,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - - statement = sa.text( - r""" - UPDATE db_dbnode - SET type = regexp_replace(type, '^node.data.', 'data.') - WHERE type LIKE 'node.data.%' - """ - ) - conn.execute(statement) + raise NotImplementedError('Downgrade of django_0025.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0026_trajectory_symbols_to_attribute.py b/aiida/backends/sqlalchemy/migrations/versions/django_0026_trajectory_symbols_to_attribute.py index fadad621ae..23aa368862 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0026_trajectory_symbols_to_attribute.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0026_trajectory_symbols_to_attribute.py @@ -56,3 +56,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0026.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0027_delete_trajectory_symbols_array.py b/aiida/backends/sqlalchemy/migrations/versions/django_0027_delete_trajectory_symbols_array.py index 2f0fa9e1b3..bcc76bd773 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0027_delete_trajectory_symbols_array.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0027_delete_trajectory_symbols_array.py @@ -62,3 +62,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0027.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0028_remove_node_prefix.py b/aiida/backends/sqlalchemy/migrations/versions/django_0028_remove_node_prefix.py index 58f91ddfab..ec60db5df5 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0028_remove_node_prefix.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0028_remove_node_prefix.py @@ -46,17 +46,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - - statement = sa.text( - r""" - UPDATE db_dbnode - SET type = regexp_replace(type, '^data.', 'node.data.') - WHERE type LIKE 'data.%'; - - UPDATE db_dbnode - SET type = regexp_replace(type, '^process.', 'node.process.') - WHERE type LIKE 'process.%'; - """ - ) - conn.execute(statement) + raise NotImplementedError('Downgrade of django_0028.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0029_rename_parameter_data_to_dict.py b/aiida/backends/sqlalchemy/migrations/versions/django_0029_rename_parameter_data_to_dict.py index 87f2977748..d0aa44f533 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0029_rename_parameter_data_to_dict.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0029_rename_parameter_data_to_dict.py @@ -39,11 +39,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - - statement = sa.text( - r""" - UPDATE db_dbnode SET type = 'data.parameter.ParameterData.' WHERE type = 'data.dict.Dict.'; - """ - ) - conn.execute(statement) + raise NotImplementedError('Downgrade of django_0029.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0030_dbnode_type_to_dbnode_node_type.py b/aiida/backends/sqlalchemy/migrations/versions/django_0030_dbnode_type_to_dbnode_node_type.py index acb75e7b18..b9e4cd9464 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0030_dbnode_type_to_dbnode_node_type.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0030_dbnode_type_to_dbnode_node_type.py @@ -32,4 +32,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.alter_column('db_dbnode', 'node_type', new_column_name='type') # pylint: disable=no-member + raise NotImplementedError('Downgrade of django_0030.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0031_remove_dbcomputer_enabled.py b/aiida/backends/sqlalchemy/migrations/versions/django_0031_remove_dbcomputer_enabled.py index 8f4d1387ba..b063e02cc9 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0031_remove_dbcomputer_enabled.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0031_remove_dbcomputer_enabled.py @@ -17,7 +17,6 @@ """ from alembic import op -import sqlalchemy as sa revision = 'django_0031' down_revision = 'django_0030' @@ -26,8 +25,10 @@ def upgrade(): + """Migrations for the upgrade.""" op.drop_column('db_dbcomputer', 'enabled') def downgrade(): - op.add_column('db_dbcomputer', sa.Column('enabled', sa.BOOLEAN(), nullable=False)) + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0031.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0032_remove_legacy_workflows.py b/aiida/backends/sqlalchemy/migrations/versions/django_0032_remove_legacy_workflows.py index b9a34330c4..bcde831f7c 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0032_remove_legacy_workflows.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0032_remove_legacy_workflows.py @@ -41,3 +41,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0032.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0033_replace_text_field_with_json_field.py b/aiida/backends/sqlalchemy/migrations/versions/django_0033_replace_text_field_with_json_field.py index f2debdb2ff..06508bb413 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0033_replace_text_field_with_json_field.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0033_replace_text_field_with_json_field.py @@ -42,3 +42,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0033.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0034_drop_node_columns_nodeversion_public.py b/aiida/backends/sqlalchemy/migrations/versions/django_0034_drop_node_columns_nodeversion_public.py index d0a15a41d1..087e8421d8 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0034_drop_node_columns_nodeversion_public.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0034_drop_node_columns_nodeversion_public.py @@ -17,7 +17,6 @@ """ from alembic import op -import sqlalchemy as sa revision = 'django_0034' down_revision = 'django_0033' @@ -26,10 +25,11 @@ def upgrade(): + """Migrations for the upgrade.""" op.drop_column('db_dbnode', 'nodeversion') op.drop_column('db_dbnode', 'public') def downgrade(): - op.add_column('db_dbnode', sa.Column('public', sa.BOOLEAN(), nullable=False)) - op.add_column('db_dbnode', sa.Column('nodeversion', sa.INTEGER(), nullable=False)) + """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0034.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0035_simplify_user_model.py b/aiida/backends/sqlalchemy/migrations/versions/django_0035_simplify_user_model.py index f55fc852c6..c7ab3bcfbf 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0035_simplify_user_model.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0035_simplify_user_model.py @@ -40,3 +40,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0035.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0036_drop_computer_transport_params.py b/aiida/backends/sqlalchemy/migrations/versions/django_0036_drop_computer_transport_params.py index f78b4d1679..b0400f8288 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0036_drop_computer_transport_params.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0036_drop_computer_transport_params.py @@ -31,3 +31,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0036.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0037_attributes_extras_settings_json.py b/aiida/backends/sqlalchemy/migrations/versions/django_0037_attributes_extras_settings_json.py index 2453e70d54..945d18efe3 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0037_attributes_extras_settings_json.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0037_attributes_extras_settings_json.py @@ -151,6 +151,7 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0037.') def attributes_to_dict(attr_list: list): diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0038_data_migration_legacy_job_calculations.py b/aiida/backends/sqlalchemy/migrations/versions/django_0038_data_migration_legacy_job_calculations.py index 55b922fa69..66c45b62ff 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0038_data_migration_legacy_job_calculations.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0038_data_migration_legacy_job_calculations.py @@ -108,3 +108,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0038.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0040_data_migration_legacy_process_attributes.py b/aiida/backends/sqlalchemy/migrations/versions/django_0040_data_migration_legacy_process_attributes.py index 0f1b8e49b2..3d59c021cf 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0040_data_migration_legacy_process_attributes.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0040_data_migration_legacy_process_attributes.py @@ -85,3 +85,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0040.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0041_seal_unsealed_processes.py b/aiida/backends/sqlalchemy/migrations/versions/django_0041_seal_unsealed_processes.py index 7f402d3026..d53ceec90c 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0041_seal_unsealed_processes.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0041_seal_unsealed_processes.py @@ -58,3 +58,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0041.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0042_prepare_schema_reset.py b/aiida/backends/sqlalchemy/migrations/versions/django_0042_prepare_schema_reset.py index 7b0c229d64..8593a62d70 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0042_prepare_schema_reset.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0042_prepare_schema_reset.py @@ -47,3 +47,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0042.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0043_default_link_label.py b/aiida/backends/sqlalchemy/migrations/versions/django_0043_default_link_label.py index 18940e1f94..5fd52c2aa5 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0043_default_link_label.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0043_default_link_label.py @@ -32,9 +32,6 @@ def upgrade(): """Migrations for the upgrade.""" conn = op.get_bind() - - # The old process functions used to use `_return` as the default link label, however, since labels that start or end - # with and underscore are illegal. statement = sa.text(""" UPDATE db_dblink SET label='result' WHERE label = '_return'; """) @@ -43,3 +40,7 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + statement = sa.text(""" + UPDATE db_dblink SET label='_result' WHERE label = 'return'; + """) + op.get_bind().execute(statement) diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0044_dbgroup_type_string.py b/aiida/backends/sqlalchemy/migrations/versions/django_0044_dbgroup_type_string.py index 503cc9be89..02530a0ae4 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0044_dbgroup_type_string.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0044_dbgroup_type_string.py @@ -29,13 +29,6 @@ """UPDATE db_dbgroup SET type_string = 'core.auto' WHERE type_string = 'auto.run';""", ] -reverse_sql = [ - """UPDATE db_dbgroup SET type_string = 'user' WHERE type_string = 'core';""", - """UPDATE db_dbgroup SET type_string = 'data.upf' WHERE type_string = 'core.upf';""", - """UPDATE db_dbgroup SET type_string = 'auto.import' WHERE type_string = 'core.import';""", - """UPDATE db_dbgroup SET type_string = 'auto.run' WHERE type_string = 'core.auto';""", -] - def upgrade(): """Migrations for the upgrade.""" @@ -46,6 +39,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - conn = op.get_bind() - statement = sa.text('\n'.join(reverse_sql)) - conn.execute(statement) + raise NotImplementedError('Downgrade of django_0044.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0045_dbgroup_extras.py b/aiida/backends/sqlalchemy/migrations/versions/django_0045_dbgroup_extras.py index dda0a86ac1..ee6e4b10e1 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0045_dbgroup_extras.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0045_dbgroup_extras.py @@ -25,7 +25,7 @@ def upgrade(): - """Upgrade: Add the extras column to the 'db_dbgroup' table""" + """Migrations for the upgrade.""" # We add the column with a `server_default` because otherwise the migration would fail since existing rows will not # have a value and violate the not-nullable clause. However, the model doesn't use a server default but a default # on the ORM level, so we remove the server default from the column directly after. @@ -36,5 +36,5 @@ def upgrade(): def downgrade(): - """Downgrade: Drop the extras column from the 'db_dbgroup' table""" + """Migrations for the downgrade.""" op.drop_column('db_dbgroup', 'extras') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0047_migrate_repository.py b/aiida/backends/sqlalchemy/migrations/versions/django_0047_migrate_repository.py index ef0eca1842..9ae077fe7f 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0047_migrate_repository.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0047_migrate_repository.py @@ -31,3 +31,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Migration of the file repository is not reversible.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0048_computer_name_to_label.py b/aiida/backends/sqlalchemy/migrations/versions/django_0048_computer_name_to_label.py index 64b485c66f..311502f945 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0048_computer_name_to_label.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0048_computer_name_to_label.py @@ -42,14 +42,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - op.drop_constraint('db_dbcomputer_label_bc480bab_uniq', 'db_dbcomputer') - op.drop_index('db_dbcomputer_label_bc480bab_like', table_name='db_dbcomputer') - op.alter_column('db_dbcomputer', 'label', new_column_name='name') - op.create_unique_constraint('db_dbcomputer_name_key', 'db_dbcomputer', ['name']) - op.create_index( - 'db_dbcomputer_name_f1800b1a_like', - 'db_dbcomputer', - ['name'], - postgresql_using='btree', - postgresql_ops={'name': 'varchar_pattern_ops'}, - ) + raise NotImplementedError('Downgrade of django_0048.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0049_entry_point_core_prefix.py b/aiida/backends/sqlalchemy/migrations/versions/django_0049_entry_point_core_prefix.py index 5d9eb77698..b1a32ad123 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0049_entry_point_core_prefix.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0049_entry_point_core_prefix.py @@ -73,3 +73,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0049.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/django_0050_sqlalchemy_parity.py b/aiida/backends/sqlalchemy/migrations/versions/django_0050_sqlalchemy_parity.py index ea15c4625b..e090306887 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/django_0050_sqlalchemy_parity.py +++ b/aiida/backends/sqlalchemy/migrations/versions/django_0050_sqlalchemy_parity.py @@ -45,3 +45,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of django_0050.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/e72ad251bcdb_dbgroup_class_change_type_string_values.py b/aiida/backends/sqlalchemy/migrations/versions/e72ad251bcdb_dbgroup_class_change_type_string_values.py index dc5ee00764..57eec0e2b1 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/e72ad251bcdb_dbgroup_class_change_type_string_values.py +++ b/aiida/backends/sqlalchemy/migrations/versions/e72ad251bcdb_dbgroup_class_change_type_string_values.py @@ -41,12 +41,14 @@ def upgrade(): + """Migrations for the upgrade.""" conn = op.get_bind() statement = text('\n'.join(forward_sql)) conn.execute(statement) def downgrade(): + """Migrations for the downgrade.""" conn = op.get_bind() statement = text('\n'.join(reverse_sql)) conn.execute(statement) diff --git a/aiida/backends/sqlalchemy/migrations/versions/e734dd5e50d7_data_migration_legacy_process_attributes.py b/aiida/backends/sqlalchemy/migrations/versions/e734dd5e50d7_data_migration_legacy_process_attributes.py index 5d1bab129c..deeb7e8e33 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/e734dd5e50d7_data_migration_legacy_process_attributes.py +++ b/aiida/backends/sqlalchemy/migrations/versions/e734dd5e50d7_data_migration_legacy_process_attributes.py @@ -90,3 +90,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" + raise NotImplementedError('Downgrade of e734dd5e50d7.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/f9a69de76a9a_delete_kombu_tables.py b/aiida/backends/sqlalchemy/migrations/versions/f9a69de76a9a_delete_kombu_tables.py index a6543778a4..10ff453aa8 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/f9a69de76a9a_delete_kombu_tables.py +++ b/aiida/backends/sqlalchemy/migrations/versions/f9a69de76a9a_delete_kombu_tables.py @@ -50,4 +50,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - print('There is no downgrade for the deletion of the kombu tables and the daemon timestamps') + raise NotImplementedError('Deletion of the kombu tables is not reversible.') diff --git a/aiida/backends/sqlalchemy/migrations/versions/main_0001_initial.py b/aiida/backends/sqlalchemy/migrations/versions/main_0001_initial.py index 1a527df68f..86382e700c 100644 --- a/aiida/backends/sqlalchemy/migrations/versions/main_0001_initial.py +++ b/aiida/backends/sqlalchemy/migrations/versions/main_0001_initial.py @@ -299,4 +299,4 @@ def upgrade(): def downgrade(): """Migrations for the downgrade.""" - raise NotImplementedError + raise NotImplementedError('Downgrade of main_0001.') diff --git a/tests/backends/aiida_sqlalchemy/migrations/sqlalchemy_branch/test_4_dblog_update.py b/tests/backends/aiida_sqlalchemy/migrations/sqlalchemy_branch/test_4_dblog_update.py index 3081303e24..c3d45bc6ad 100644 --- a/tests/backends/aiida_sqlalchemy/migrations/sqlalchemy_branch/test_4_dblog_update.py +++ b/tests/backends/aiida_sqlalchemy/migrations/sqlalchemy_branch/test_4_dblog_update.py @@ -258,91 +258,6 @@ def test_metadata_correctness(self): assert 'objname' not in m_res.keys(), 'objname should not exist any more in metadata' -def test_backward_migration(perform_migrations: PsqlDostoreMigrator): - """Check that backward migrations work also for the DbLog migration(s). - - This test verifies that the objpk and objname have the right values - after a forward and a backward migration. - """ - # starting revision - perform_migrations.migrate_up('sqlalchemy@041a79fc615f') # 041a79fc615f_dblog_cleaning - - # setup the database - DbLog = perform_migrations.get_current_table('db_dblog') # pylint: disable=invalid-name - DbNode = perform_migrations.get_current_table('db_dbnode') # pylint: disable=invalid-name - DbUser = perform_migrations.get_current_table('db_dbuser') # pylint: disable=invalid-name - with perform_migrations.session() as session: - user = DbUser(email='user@aiida.net', is_superuser=True) - session.add(user) - session.commit() - - calc_1 = DbNode(type='node.process.calculation.CalculationNode.1', user_id=user.id) - calc_2 = DbNode(type='node.process.calculation.CalculationNode.2', user_id=user.id) - - session.add(calc_1) - session.add(calc_2) - session.commit() - - log_1 = DbLog( - loggername='CalculationNode logger', - dbnode_id=calc_1.id, - message='calculation node 1', - metadata={ - 'msecs': 719.0849781036377, - 'lineno': 350, - 'thread': 140011612940032, - 'asctime': '10/21/2018 12:39:51 PM', - 'created': 1540118391.719085, - 'levelno': 23, - 'message': 'calculation node 1', - }) - log_2 = DbLog( - loggername='CalculationNode logger', - dbnode_id=calc_2.id, - message='calculation node 2', - metadata={ - 'msecs': 719.0849781036377, - 'lineno': 360, - 'levelno': 23, - 'message': 'calculation node 1', - }) - - session.add(log_1) - session.add(log_2) - - session.commit() - - # Keeping what is needed to be verified at the test - to_check = { - log_1.id: (log_1.dbnode_id, calc_1.type), - log_2.id: (log_2.dbnode_id, calc_2.type) - } - - # migrate down - perform_migrations.migrate_down('sqlalchemy@7ca08c391c49') # e72ad251bcdb_dbgroup_class_change_type_string_values - - # perform some checks - DbLog = perform_migrations.get_current_table('db_dblog') # pylint: disable=invalid-name - with perform_migrations.session() as session: - - for log_pk, to_check_value in to_check.items(): - log_entry = session.query(DbLog).filter(DbLog.id == log_pk).one() - log_dbnode_id, node_type = to_check_value - - assert log_dbnode_id == log_entry.objpk, ( - f'The dbnode_id ({log_dbnode_id}) of the 0024 schema version ' - f'should be identical to the objpk ({log_entry.objpk}) of the 0023 schema version.') - assert node_type == log_entry.objname, ( - f'The type ({node_type}) of the linked node of the 0024 schema version should be identical to the ' - f'objname ({log_entry.objname}) of the 0023 schema version.') - assert log_dbnode_id == log_entry.metadata['objpk'], ( - f'The dbnode_id ({log_dbnode_id}) of the 0024 schema version should be identical to the ' - f'objpk ({log_entry.metadata["objpk"]}) of the 0023 schema version stored in the metadata.') - assert node_type == log_entry.metadata['objname'], ( - f'The type ({node_type}) of the linked node of the 0024 schema version should be identical to the ' - f'objname ({log_entry.metadata["objname"]}) of the 0023 schema version stored in the metadata.') - - def test_dblog_uuid_addition(perform_migrations: PsqlDostoreMigrator): """Test that the UUID column is correctly added to the DbLog table, and that the uniqueness constraint is added without problems