This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/migrations/versions/b4c2d45bc132_add_deleted_namespace_table.py
Joseph Schorr 8bc55a5676 Make namespace deletion asynchronous
Instead of deleting a namespace synchronously as before, we now mark the namespace for deletion, disable it, and rename it. A worker then comes along and deletes the namespace in the background. This results in a *significantly* better user experience, as the namespace deletion operation now "completes" in under a second, where before it could take 10s of minutes at the worse.

Fixes https://jira.coreos.com/browse/QUAY-838
2018-02-27 13:12:51 -05:00

39 lines
1.6 KiB
Python

"""Add deleted namespace table
Revision ID: b4c2d45bc132
Revises: 152edccba18c
Create Date: 2018-02-27 11:43:02.329941
"""
# revision identifiers, used by Alembic.
revision = 'b4c2d45bc132'
down_revision = '152edccba18c'
from alembic import op
import sqlalchemy as sa
def upgrade(tables):
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('deletednamespace',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('namespace_id', sa.Integer(), nullable=False),
sa.Column('marked', sa.DateTime(), nullable=False),
sa.Column('original_username', sa.String(length=255), nullable=False),
sa.Column('original_email', sa.String(length=255), nullable=False),
sa.Column('queue_id', sa.String(length=255), nullable=True),
sa.ForeignKeyConstraint(['namespace_id'], ['user.id'], name=op.f('fk_deletednamespace_namespace_id_user')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_deletednamespace'))
)
op.create_index('deletednamespace_namespace_id', 'deletednamespace', ['namespace_id'], unique=True)
op.create_index('deletednamespace_original_email', 'deletednamespace', ['original_email'], unique=False)
op.create_index('deletednamespace_original_username', 'deletednamespace', ['original_username'], unique=False)
op.create_index('deletednamespace_queue_id', 'deletednamespace', ['queue_id'], unique=False)
# ### end Alembic commands ###
def downgrade(tables):
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('deletednamespace')
# ### end Alembic commands ###