- Update the migrations tool to verify migrations work up and down for both MySQL and PostgresSQL.

- Add migrations for the squashed image tables and for backfilling the uncompressed sizes
- Make sure gzip stream uses a max length when determining the uncompressed size
This commit is contained in:
Joseph Schorr 2014-10-07 15:29:56 -04:00
parent f38ce51943
commit f4daa5e97b
10 changed files with 152 additions and 43 deletions

View file

@ -0,0 +1,22 @@
"""Calculate uncompressed sizes for all images
Revision ID: 2430f55c41d5
Revises: 3b4d3a4461dc
Create Date: 2014-10-07 14:50:04.660315
"""
# revision identifiers, used by Alembic.
revision = '2430f55c41d5'
down_revision = '3b4d3a4461dc'
from alembic import op
import sqlalchemy as sa
from util.uncompressedsize import backfill_sizes_from_data
def upgrade(tables):
backfill_sizes_from_data()
def downgrade(tables):
pass

View file

@ -1,25 +1,24 @@
"""add support for squashing images
"""Add support for squashed images
Revision ID: 3f6d26399bd2
Revises: 34fd69f63809
Create Date: 2014-09-22 14:37:30.821785
Revision ID: 3b4d3a4461dc
Revises: b1d41e2071b
Create Date: 2014-10-07 14:49:13.105746
"""
# revision identifiers, used by Alembic.
revision = '3f6d26399bd2'
down_revision = '34fd69f63809'
revision = '3b4d3a4461dc'
down_revision = 'b1d41e2071b'
from alembic import op
import sqlalchemy as sa
def upgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.create_table('imagestoragetransformation',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.PrimaryKeyConstraint('id')
sa.PrimaryKeyConstraint('id', name=op.f('pk_imagestoragetransformation'))
)
op.create_index('imagestoragetransformation_name', 'imagestoragetransformation', ['name'], unique=True)
op.create_table('derivedimagestorage',
@ -27,10 +26,10 @@ def upgrade(tables):
sa.Column('source_id', sa.Integer(), nullable=True),
sa.Column('derivative_id', sa.Integer(), nullable=False),
sa.Column('transformation_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['derivative_id'], ['imagestorage.id'], ),
sa.ForeignKeyConstraint(['source_id'], ['imagestorage.id'], ),
sa.ForeignKeyConstraint(['transformation_id'], ['imagestoragetransformation.id'], ),
sa.PrimaryKeyConstraint('id')
sa.ForeignKeyConstraint(['derivative_id'], ['imagestorage.id'], name=op.f('fk_derivedimagestorage_derivative_id_imagestorage')),
sa.ForeignKeyConstraint(['source_id'], ['imagestorage.id'], name=op.f('fk_derivedimagestorage_source_id_imagestorage')),
sa.ForeignKeyConstraint(['transformation_id'], ['imagestoragetransformation.id'], name=op.f('fk_dis_transformation_id_ist')),
sa.PrimaryKeyConstraint('id', name=op.f('pk_derivedimagestorage'))
)
op.create_index('derivedimagestorage_derivative_id', 'derivedimagestorage', ['derivative_id'], unique=False)
op.create_index('derivedimagestorage_source_id', 'derivedimagestorage', ['source_id'], unique=False)
@ -38,18 +37,21 @@ def upgrade(tables):
op.create_index('derivedimagestorage_transformation_id', 'derivedimagestorage', ['transformation_id'], unique=False)
op.drop_index('image_repository_id_docker_image_id', table_name='image')
op.create_index('image_repository_id_docker_image_id', 'image', ['repository_id', 'docker_image_id'], unique=True)
op.drop_index('imagestorage_uuid', table_name='imagestorage')
op.create_index('imagestorage_uuid', 'imagestorage', ['uuid'], unique=False)
op.drop_column(u'repository', 'namespace')
op.create_index('repository_namespace_user_id', 'repository', ['namespace_user_id'], unique=False)
### end Alembic commands ###
def downgrade(tables):
### commands auto generated by Alembic - please adjust! ###
op.drop_index('repository_namespace_user_id', table_name='repository')
op.add_column(u'repository', sa.Column('namespace', sa.String(length=255), nullable=True))
op.drop_index('imagestorage_uuid', table_name='imagestorage')
op.create_index('imagestorage_uuid', 'imagestorage', ['uuid'], unique=True)
op.drop_index('image_repository_id_docker_image_id', table_name='image')
op.create_index('image_repository_id_docker_image_id', 'image', ['repository_id', 'docker_image_id'], unique=False)
op.drop_index('derivedimagestorage_transformation_id', table_name='derivedimagestorage')
op.drop_index('derivedimagestorage_source_id_transformation_id', table_name='derivedimagestorage')
op.drop_index('derivedimagestorage_source_id', table_name='derivedimagestorage')
op.drop_index('derivedimagestorage_derivative_id', table_name='derivedimagestorage')
op.drop_table('derivedimagestorage')
op.drop_index('imagestoragetransformation_name', table_name='imagestoragetransformation')
op.drop_table('imagestoragetransformation')
### end Alembic commands ###