From f16878cce91aa9a7d8c1b7626759abb564533058 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 22 Sep 2014 14:38:42 -0400 Subject: [PATCH] Add migration for synthetic image tables --- ...399bd2_add_support_for_squashing_images.py | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 data/migrations/versions/3f6d26399bd2_add_support_for_squashing_images.py diff --git a/data/migrations/versions/3f6d26399bd2_add_support_for_squashing_images.py b/data/migrations/versions/3f6d26399bd2_add_support_for_squashing_images.py new file mode 100644 index 000000000..043d68db8 --- /dev/null +++ b/data/migrations/versions/3f6d26399bd2_add_support_for_squashing_images.py @@ -0,0 +1,57 @@ +"""add support for squashing images + +Revision ID: 3f6d26399bd2 +Revises: 34fd69f63809 +Create Date: 2014-09-22 14:37:30.821785 + +""" + +# revision identifiers, used by Alembic. +revision = '3f6d26399bd2' +down_revision = '34fd69f63809' + +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') + ) + op.create_index('imagestoragetransformation_name', 'imagestoragetransformation', ['name'], unique=True) + op.create_table('derivedimagestorage', + sa.Column('id', sa.Integer(), nullable=False), + 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') + ) + op.create_index('derivedimagestorage_derivative_id', 'derivedimagestorage', ['derivative_id'], unique=False) + op.create_index('derivedimagestorage_source_id', 'derivedimagestorage', ['source_id'], unique=False) + op.create_index('derivedimagestorage_source_id_transformation_id', 'derivedimagestorage', ['source_id', 'transformation_id'], unique=True) + 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.add_column(u'imagestorage', sa.Column('uncompressed_size', sa.BigInteger(), nullable=True)) + ### end Alembic commands ### + + +def downgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column(u'imagestorage', 'uncompressed_size') + 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 ###