diff --git a/data/migrations/versions/c00a1f15968b_add_schema2_media_types.py b/data/migrations/versions/c00a1f15968b_add_schema2_media_types.py new file mode 100644 index 000000000..26c3b5170 --- /dev/null +++ b/data/migrations/versions/c00a1f15968b_add_schema2_media_types.py @@ -0,0 +1,31 @@ +from image.docker.schema2 import DOCKER_SCHEMA2_CONTENT_TYPES + +"""Add schema2 media types + +Revision ID: c00a1f15968b +Revises: 67f0abd172ae +Create Date: 2018-11-13 09:20:21.968503 + +""" + +# revision identifiers, used by Alembic. +revision = 'c00a1f15968b' +down_revision = '67f0abd172ae' + +from alembic import op + +def upgrade(tables, tester): + for media_type in DOCKER_SCHEMA2_CONTENT_TYPES: + op.bulk_insert(tables.mediatype, + [ + {'name': media_type}, + ]) + + +def downgrade(tables, tester): + for media_type in DOCKER_SCHEMA2_CONTENT_TYPES: + op.execute(tables + .mediatype + .delete() + .where(tables. + mediatype.c.name == op.inline_literal(media_type)))