def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("queueitem_state_id", table_name="queueitem") op.create_index("queueitem_state_id", "queueitem", ["state_id"], unique=False)
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_column(u"repositorybuildtrigger", "secure_private_key") op.drop_column(u"repositorybuildtrigger", "secure_auth_token") op.drop_index("oauthauthorizationcode_code", table_name="oauthauthorizationcode") op.create_index("oauthauthorizationcode_code", "oauthauthorizationcode", ["code"], unique=False) op.drop_index("oauthauthorizationcode_code_name", table_name="oauthauthorizationcode") op.drop_column(u"oauthauthorizationcode", "code_name") op.drop_column(u"oauthauthorizationcode", "code_credential") op.drop_column(u"oauthapplication", "secure_client_secret") op.drop_index("oauthaccesstoken_token_name", table_name="oauthaccesstoken") op.drop_column(u"oauthaccesstoken", "token_name") op.drop_column(u"oauthaccesstoken", "token_code") op.drop_column(u"emailconfirmation", "verification_code") op.drop_index("appspecificauthtoken_token_name", table_name="appspecificauthtoken") op.drop_column(u"appspecificauthtoken", "token_secret") op.drop_column(u"appspecificauthtoken", "token_name") op.drop_index("accesstoken_token_name", table_name="accesstoken") op.drop_column(u"accesstoken", "token_name") op.drop_column(u"accesstoken", "token_code") op.drop_table("robotaccounttoken")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_column(u'repositorybuildtrigger', 'secure_private_key') op.drop_column(u'repositorybuildtrigger', 'secure_auth_token') op.drop_index('oauthauthorizationcode_code', table_name='oauthauthorizationcode') op.create_index('oauthauthorizationcode_code', 'oauthauthorizationcode', ['code'], unique=False) op.drop_index('oauthauthorizationcode_code_name', table_name='oauthauthorizationcode') op.drop_column(u'oauthauthorizationcode', 'code_name') op.drop_column(u'oauthauthorizationcode', 'code_credential') op.drop_column(u'oauthapplication', 'secure_client_secret') op.drop_index('oauthaccesstoken_token_name', table_name='oauthaccesstoken') op.drop_column(u'oauthaccesstoken', 'token_name') op.drop_column(u'oauthaccesstoken', 'token_code') op.drop_column(u'emailconfirmation', 'verification_code') op.drop_index('appspecificauthtoken_token_name', table_name='appspecificauthtoken') op.drop_column(u'appspecificauthtoken', 'token_secret') op.drop_column(u'appspecificauthtoken', 'token_name') op.drop_index('accesstoken_token_name', table_name='accesstoken') op.drop_column(u'accesstoken', 'token_name') op.drop_column(u'accesstoken', 'token_code') op.drop_table('robotaccounttoken')
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) op.drop_constraint(op.f("fk_repository_kind_id_repositorykind"), "repository", type_="foreignkey") op.drop_index("repository_kind_id", table_name="repository") op.drop_column(u"repository", "kind_id") op.drop_table("repositorykind")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) op.drop_constraint(op.f('fk_repository_kind_id_repositorykind'), 'repository', type_='foreignkey') op.drop_index('repository_kind_id', table_name='repository') op.drop_column(u'repository', 'kind_id') op.drop_table('repositorykind')
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("oauthaccesstoken_refresh_token", table_name="oauthaccesstoken") op.drop_column(u"oauthaccesstoken", "refresh_token") op.drop_column("accesstoken", "code") op.drop_column("appspecificauthtoken", "token_code") op.drop_column("oauthaccesstoken", "access_token") op.drop_column("oauthapplication", "client_secret") op.drop_column("oauthauthorizationcode", "code") op.drop_column("repositorybuildtrigger", "private_key") op.drop_column("repositorybuildtrigger", "auth_token") # ### end Alembic commands ### # Overwrite all plaintext robot credentials. from app import app if app.config.get("SETUP_COMPLETE", False) or tester.is_testing(): while True: try: robot_account_token = RobotAccountToken.get(fully_migrated=False) logger.debug("Found robot account token %s migrate", robot_account_token.id) robot_account = robot_account_token.robot_account assert robot_account.robot result = ( User.update(email=str(uuid.uuid4())) .where( User.id == robot_account.id, User.robot == True, User.uuid == robot_account.uuid, ) .execute() ) assert result == 1 try: federated_login = FederatedLogin.get(user=robot_account) assert federated_login.service.name == "quayrobot" federated_login.service_ident = "robot:%s" % robot_account.id federated_login.save() except FederatedLogin.DoesNotExist: pass robot_account_token.fully_migrated = True robot_account_token.save() logger.debug("Finished migrating robot account token %s", robot_account_token.id) except RobotAccountToken.DoesNotExist: break
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # Backfill the queueitem table's state_id field with unique values for all entries which are # empty. conn = op.get_bind() conn.execute("update queueitem set state_id = id where state_id = ''") # ### commands auto generated by Alembic - please adjust! ### op.drop_index("queueitem_state_id", table_name="queueitem") op.create_index("queueitem_state_id", "queueitem", ["state_id"], unique=True)
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_index('queueitem_processing_expires_available', 'queueitem', ['processing_expires', 'available'], unique=False) op.create_index('queueitem_pe_aafter_qname_rremaining_available', 'queueitem', [ 'processing_expires', 'available_after', 'queue_name', 'retries_remaining', 'available' ], unique=False) op.create_index('queueitem_pexpires_aafter_rremaining_available', 'queueitem', [ 'processing_expires', 'available_after', 'retries_remaining', 'available' ], unique=False) op.create_index('queueitem_processing_expires_queue_name_available', 'queueitem', ['processing_expires', 'queue_name', 'available'], unique=False) op.drop_index('queueitem_available', table_name='queueitem') op.drop_index('queueitem_available_after', table_name='queueitem') op.drop_index('queueitem_processing_expires', table_name='queueitem') op.drop_index('queueitem_retries_remaining', table_name='queueitem')
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("tag_repository_id_lifetime_end_ms", table_name="tag") op.drop_index("repositorytag_repository_id_lifetime_end_ts", table_name="repositorytag") op.drop_index("tag_repository_id_lifetime_start_ms", table_name="tag") op.drop_index("repositorytag_repository_id_lifetime_start_ts", table_name="repositorytag")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint( op.f('fk_repositorybuildtrigger_disabled_reason_id_disablereason'), 'repositorybuildtrigger', type_='foreignkey') op.drop_index('repositorybuildtrigger_disabled_reason_id', table_name='repositorybuildtrigger') op.drop_column(u'repositorybuildtrigger', 'enabled') op.drop_column(u'repositorybuildtrigger', 'disabled_reason_id') op.drop_table('disablereason') # ### end Alembic commands ### op.execute(tables.logentrykind.delete().where( tables.logentrykind.c.name == op.inline_literal( 'toggle_repo_trigger')))
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint( op.f("fk_repositorybuildtrigger_disabled_reason_id_disablereason"), "repositorybuildtrigger", type_="foreignkey", ) op.drop_index("repositorybuildtrigger_disabled_reason_id", table_name="repositorybuildtrigger") op.drop_column(u"repositorybuildtrigger", "enabled") op.drop_column(u"repositorybuildtrigger", "disabled_reason_id") op.drop_table("disablereason") # ### end Alembic commands ### op.execute(tables.logentrykind.delete().where( tables.logentrykind.c.name == op.inline_literal( "toggle_repo_trigger")))
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("oauthaccesstoken_refresh_token", table_name="oauthaccesstoken") op.drop_column(u"oauthaccesstoken", "refresh_token") op.drop_column("accesstoken", "code") op.drop_column("appspecificauthtoken", "token_code") op.drop_column("oauthaccesstoken", "access_token") op.drop_column("oauthapplication", "client_secret") op.drop_column("oauthauthorizationcode", "code") op.drop_column("repositorybuildtrigger", "private_key") op.drop_column("repositorybuildtrigger", "auth_token") # ### end Alembic commands ### # Overwrite all plaintext robot credentials. from app import app if app.config.get("SETUP_COMPLETE", False) or tester.is_testing(): while True: try: robot_account_token = RobotAccountToken.get( fully_migrated=False) robot_account = robot_account_token.robot_account robot_account.email = str(uuid.uuid4()) robot_account.save() federated_login = FederatedLogin.get(user=robot_account) federated_login.service_ident = "robot:%s" % robot_account.id federated_login.save() robot_account_token.fully_migrated = True robot_account_token.save() except RobotAccountToken.DoesNotExist: break
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("user_uuid", table_name="user") op.drop_index("repositorybuildtrigger_uuid", table_name="repositorybuildtrigger") op.drop_index("permissionprototype_uuid", table_name="permissionprototype")
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index('oauthaccesstoken_refresh_token', table_name='oauthaccesstoken') op.drop_column(u'oauthaccesstoken', 'refresh_token') op.drop_column('accesstoken', 'code') op.drop_column('appspecificauthtoken', 'token_code') op.drop_column('oauthaccesstoken', 'access_token') op.drop_column('oauthapplication', 'client_secret') op.drop_column('oauthauthorizationcode', 'code') op.drop_column('repositorybuildtrigger', 'private_key') op.drop_column('repositorybuildtrigger', 'auth_token') # ### end Alembic commands ### # Overwrite all plaintext robot credentials. while True: try: robot_account_token = RobotAccountToken.get(fully_migrated=False) robot_account = robot_account_token.robot_account robot_account.email = str(uuid.uuid4()) robot_account.save() federated_login = FederatedLogin.get(user=robot_account) federated_login.service_ident = 'robot:%s' % robot_account.id federated_login.save() robot_account_token.fully_migrated = True robot_account_token.save() except RobotAccountToken.DoesNotExist: break
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) ### commands auto generated by Alembic - please adjust! ### op.create_index("queueitem_retries_remaining", "queueitem", ["retries_remaining"], unique=False) op.create_index("queueitem_processing_expires", "queueitem", ["processing_expires"], unique=False) op.create_index("queueitem_available_after", "queueitem", ["available_after"], unique=False) op.create_index("queueitem_available", "queueitem", ["available"], unique=False) op.drop_index("queueitem_processing_expires_queue_name_available", table_name="queueitem") op.drop_index("queueitem_pexpires_aafter_rremaining_available", table_name="queueitem") op.drop_index("queueitem_pe_aafter_qname_rremaining_available", table_name="queueitem") op.drop_index("queueitem_processing_expires_available", table_name="queueitem")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint(op.f('fk_messages_media_type_id_mediatype'), 'messages', type_='foreignkey') op.drop_index('messages_uuid', table_name='messages') op.drop_index('messages_severity', table_name='messages') op.drop_index('messages_media_type_id', table_name='messages') op.alter_column('messages', 'uuid', existing_type=mysql.VARCHAR(length=36), nullable=True) op.drop_column('messages', 'severity') op.drop_column('messages', 'media_type_id') # ### end Alembic commands ### op.execute(tables.mediatype.delete().where( tables.mediatype.c.name == op.inline_literal('text/markdown')))
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint(op.f("fk_messages_media_type_id_mediatype"), "messages", type_="foreignkey") op.drop_index("messages_uuid", table_name="messages") op.drop_index("messages_severity", table_name="messages") op.drop_index("messages_media_type_id", table_name="messages") op.alter_column("messages", "uuid", existing_type=mysql.VARCHAR(length=36), nullable=True) op.drop_column("messages", "severity") op.drop_column("messages", "media_type_id") # ### end Alembic commands ### op.execute(tables.mediatype.delete().where( tables.mediatype.c.name == op.inline_literal("text/markdown")))
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( "robotaccounttoken", sa.Column("id", sa.Integer(), nullable=False), sa.Column("robot_account_id", sa.Integer(), nullable=False), sa.Column("token", sa.String(length=255), nullable=False), sa.Column("fully_migrated", sa.Boolean(), nullable=False, server_default="0"), sa.ForeignKeyConstraint( ["robot_account_id"], ["user.id"], name=op.f("fk_robotaccounttoken_robot_account_id_user"), ), sa.PrimaryKeyConstraint("id", name=op.f("pk_robotaccounttoken")), ) op.create_index("robotaccounttoken_robot_account_id", "robotaccounttoken", ["robot_account_id"], unique=True) op.add_column( u"accesstoken", sa.Column("token_code", sa.String(length=255), nullable=True)) op.add_column( u"accesstoken", sa.Column("token_name", sa.String(length=255), nullable=True)) op.create_index("accesstoken_token_name", "accesstoken", ["token_name"], unique=True) op.add_column( u"appspecificauthtoken", sa.Column("token_name", sa.String(length=255), nullable=True)) op.add_column( u"appspecificauthtoken", sa.Column("token_secret", sa.String(length=255), nullable=True)) op.create_index("appspecificauthtoken_token_name", "appspecificauthtoken", ["token_name"], unique=True) op.add_column( u"emailconfirmation", sa.Column("verification_code", sa.String(length=255), nullable=True)) op.add_column( u"oauthaccesstoken", sa.Column("token_code", sa.String(length=255), nullable=True)) op.add_column( u"oauthaccesstoken", sa.Column("token_name", sa.String(length=255), nullable=True)) op.create_index("oauthaccesstoken_token_name", "oauthaccesstoken", ["token_name"], unique=True) op.add_column( u"oauthapplication", sa.Column("secure_client_secret", sa.String(length=255), nullable=True)) op.add_column( u"oauthapplication", sa.Column("fully_migrated", sa.Boolean(), server_default="0", nullable=False), ) op.add_column( u"oauthauthorizationcode", sa.Column("code_credential", sa.String(length=255), nullable=True), ) op.add_column(u"oauthauthorizationcode", sa.Column("code_name", sa.String(length=255), nullable=True)) op.create_index("oauthauthorizationcode_code_name", "oauthauthorizationcode", ["code_name"], unique=True) op.drop_index("oauthauthorizationcode_code", table_name="oauthauthorizationcode") op.create_index("oauthauthorizationcode_code", "oauthauthorizationcode", ["code"], unique=True) op.add_column( u"repositorybuildtrigger", sa.Column("secure_auth_token", sa.String(length=255), nullable=True), ) op.add_column(u"repositorybuildtrigger", sa.Column("secure_private_key", sa.Text(), nullable=True)) op.add_column( u"repositorybuildtrigger", sa.Column("fully_migrated", sa.Boolean(), server_default="0", nullable=False), ) # ### end Alembic commands ### # ### population of test data ### # tester.populate_table( "robotaccounttoken", [ ("robot_account_id", tester.TestDataType.Foreign("user")), ("token", tester.TestDataType.Token), ("fully_migrated", tester.TestDataType.Boolean), ], ) tester.populate_column("accesstoken", "code", tester.TestDataType.Token) tester.populate_column("appspecificauthtoken", "token_code", tester.TestDataType.Token) tester.populate_column("emailconfirmation", "verification_code", tester.TestDataType.Token) tester.populate_column("oauthaccesstoken", "token_code", tester.TestDataType.Token)
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index('repositorybuildtrigger_disabled_datetime', table_name='repositorybuildtrigger') op.drop_column('repositorybuildtrigger', 'disabled_datetime')
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("manifestblob_manifest_id_blob_index", table_name="manifestblob") op.drop_column("manifestblob", "blob_index")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("repository_name__fulltext", table_name="repository") op.drop_index("repository_description__fulltext", table_name="repository")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("user_last_accessed", table_name="user") op.drop_column("user", "last_accessed")
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index("repositorybuild_logs_archived", table_name="repositorybuild")
def upgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.create_table( 'robotaccounttoken', sa.Column('id', sa.Integer(), nullable=False), sa.Column('robot_account_id', sa.Integer(), nullable=False), sa.Column('token', sa.String(length=255), nullable=False), sa.Column('fully_migrated', sa.Boolean(), nullable=False, server_default='0'), sa.ForeignKeyConstraint( ['robot_account_id'], ['user.id'], name=op.f('fk_robotaccounttoken_robot_account_id_user')), sa.PrimaryKeyConstraint('id', name=op.f('pk_robotaccounttoken'))) op.create_index('robotaccounttoken_robot_account_id', 'robotaccounttoken', ['robot_account_id'], unique=True) op.add_column( u'accesstoken', sa.Column('token_code', sa.String(length=255), nullable=True)) op.add_column( u'accesstoken', sa.Column('token_name', sa.String(length=255), nullable=True)) op.create_index('accesstoken_token_name', 'accesstoken', ['token_name'], unique=True) op.add_column( u'appspecificauthtoken', sa.Column('token_name', sa.String(length=255), nullable=True)) op.add_column( u'appspecificauthtoken', sa.Column('token_secret', sa.String(length=255), nullable=True)) op.create_index('appspecificauthtoken_token_name', 'appspecificauthtoken', ['token_name'], unique=True) op.add_column( u'emailconfirmation', sa.Column('verification_code', sa.String(length=255), nullable=True)) op.add_column( u'oauthaccesstoken', sa.Column('token_code', sa.String(length=255), nullable=True)) op.add_column( u'oauthaccesstoken', sa.Column('token_name', sa.String(length=255), nullable=True)) op.create_index('oauthaccesstoken_token_name', 'oauthaccesstoken', ['token_name'], unique=True) op.add_column( u'oauthapplication', sa.Column('secure_client_secret', sa.String(length=255), nullable=True)) op.add_column( u'oauthapplication', sa.Column('fully_migrated', sa.Boolean(), server_default='0', nullable=False)) op.add_column( u'oauthauthorizationcode', sa.Column('code_credential', sa.String(length=255), nullable=True)) op.add_column(u'oauthauthorizationcode', sa.Column('code_name', sa.String(length=255), nullable=True)) op.create_index('oauthauthorizationcode_code_name', 'oauthauthorizationcode', ['code_name'], unique=True) op.drop_index('oauthauthorizationcode_code', table_name='oauthauthorizationcode') op.create_index('oauthauthorizationcode_code', 'oauthauthorizationcode', ['code'], unique=True) op.add_column( u'repositorybuildtrigger', sa.Column('secure_auth_token', sa.String(length=255), nullable=True)) op.add_column(u'repositorybuildtrigger', sa.Column('secure_private_key', sa.Text(), nullable=True)) op.add_column( u'repositorybuildtrigger', sa.Column('fully_migrated', sa.Boolean(), server_default='0', nullable=False)) # ### end Alembic commands ### # ### population of test data ### # tester.populate_table('robotaccounttoken', [ ('robot_account_id', tester.TestDataType.Foreign('user')), ('token', tester.TestDataType.Token), ('fully_migrated', tester.TestDataType.Boolean), ]) tester.populate_column('accesstoken', 'code', tester.TestDataType.Token) tester.populate_column('appspecificauthtoken', 'token_code', tester.TestDataType.Token) tester.populate_column('emailconfirmation', 'verification_code', tester.TestDataType.Token) tester.populate_column('oauthaccesstoken', 'token_code', tester.TestDataType.Token)
def downgrade(tables, tester, progress_reporter): op = ProgressWrapper(original_op, progress_reporter) # ### commands auto generated by Alembic - please adjust! ### op.drop_index('queueitem_state_id', table_name='queueitem') op.drop_column('queueitem', 'state_id')