From d77d383e46ea683ffde0ab4ddd151a58307b769f Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 13 Nov 2018 09:24:04 +0200 Subject: [PATCH] Add schema2 media types --- .../c00a1f15968b_add_schema2_media_types.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 data/migrations/versions/c00a1f15968b_add_schema2_media_types.py 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)))