From 148527664d2dcc5df541a55b676c989a6ff6ac55 Mon Sep 17 00:00:00 2001 From: Tom McKay Date: Thu, 21 Nov 2019 08:20:09 -0500 Subject: [PATCH] PROJQUAY-19 - correct migration logic --- data/migrations/versions/34c8ef052ec9_repo_mirror_columns.py | 4 ++-- .../versions/703298a825c2_backfill_new_encrypted_fields.py | 2 +- .../c059b952ed76_remove_unencrypted_fields_and_data.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data/migrations/versions/34c8ef052ec9_repo_mirror_columns.py b/data/migrations/versions/34c8ef052ec9_repo_mirror_columns.py index 2b73b8afa..78b74dd63 100644 --- a/data/migrations/versions/34c8ef052ec9_repo_mirror_columns.py +++ b/data/migrations/versions/34c8ef052ec9_repo_mirror_columns.py @@ -81,7 +81,7 @@ def upgrade(tables, tester, progress_reporter): op.add_column('repomirrorconfig', sa.Column('external_reference', sa.Text(), nullable=True)) from app import app - if app.config.get('SETUP_COMPLETE', False) or tester.is_testing: + if not app.config.get('SETUP_COMPLETE', False) or tester.is_testing: for repo_mirror in _iterate(RepoMirrorConfig, (RepoMirrorConfig.external_reference >> None)): repo = '%s/%s/%s' % (repo_mirror.external_registry, repo_mirror.external_namespace, repo_mirror.external_repository) logger.info('migrating %s' % repo) @@ -112,7 +112,7 @@ def downgrade(tables, tester, progress_reporter): op.add_column('repomirrorconfig', sa.Column('external_repository', sa.String(length=255), nullable=True)) from app import app - if app.config.get('SETUP_COMPLETE', False): + if not app.config.get('SETUP_COMPLETE', False): logger.info('Restoring columns from external_reference') for repo_mirror in _iterate(RepoMirrorConfig, (RepoMirrorConfig.external_registry >> None)): logger.info('Restoring %s' % repo_mirror.external_reference) diff --git a/data/migrations/versions/703298a825c2_backfill_new_encrypted_fields.py b/data/migrations/versions/703298a825c2_backfill_new_encrypted_fields.py index 43459af40..f62631613 100644 --- a/data/migrations/versions/703298a825c2_backfill_new_encrypted_fields.py +++ b/data/migrations/versions/703298a825c2_backfill_new_encrypted_fields.py @@ -99,7 +99,7 @@ def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) from app import app - if app.config.get('SETUP_COMPLETE', False) or tester.is_testing: + if not app.config.get('SETUP_COMPLETE', False) or tester.is_testing: # Empty all access token names to fix the bug where we put the wrong name and code # in for some tokens. AccessToken.update(token_name=None).where(AccessToken.token_name >> None).execute() diff --git a/data/migrations/versions/c059b952ed76_remove_unencrypted_fields_and_data.py b/data/migrations/versions/c059b952ed76_remove_unencrypted_fields_and_data.py index 4854630bf..640061d42 100644 --- a/data/migrations/versions/c059b952ed76_remove_unencrypted_fields_and_data.py +++ b/data/migrations/versions/c059b952ed76_remove_unencrypted_fields_and_data.py @@ -40,7 +40,7 @@ def upgrade(tables, tester, progress_reporter): # Overwrite all plaintext robot credentials. from app import app - if app.config.get('SETUP_COMPLETE', False) or tester.is_testing: + if not app.config.get('SETUP_COMPLETE', False) or tester.is_testing: while True: try: robot_account_token = RobotAccountToken.get(fully_migrated=False)