From 4191d690556cf277b72967c5300c359f13a348e5 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Fri, 23 Oct 2015 15:50:31 -0400 Subject: [PATCH] Switch Text to LongText for MySQL manifests --- ...da62_switch_manifest_text_to_a_longtext.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 data/migrations/versions/35f538da62_switch_manifest_text_to_a_longtext.py diff --git a/data/migrations/versions/35f538da62_switch_manifest_text_to_a_longtext.py b/data/migrations/versions/35f538da62_switch_manifest_text_to_a_longtext.py new file mode 100644 index 000000000..f11b5336a --- /dev/null +++ b/data/migrations/versions/35f538da62_switch_manifest_text_to_a_longtext.py @@ -0,0 +1,47 @@ +"""Switch manifest text to a longtext. + +Revision ID: 35f538da62 +Revises: 33bd39ef5ed6 +Create Date: 2015-10-23 15:31:27.353995 + +""" + +# revision identifiers, used by Alembic. +revision = '35f538da62' +down_revision = '33bd39ef5ed6' + +from alembic import op +import sqlalchemy as sa + +from sqlalchemy.types import TypeDecorator, Text +from sqlalchemy.dialects.mysql import LONGTEXT +import uuid + +class EngineLongText(TypeDecorator): + """Platform-independent LongText type. + + Uses MySQL's LONGTEXT type, otherwise uses + Text, because other engines are not as limited + as MySQL. + + """ + impl = Text + + def load_dialect_impl(self, dialect): + if dialect.name == 'mysql': + return dialect.type_descriptor(LONGTEXT()) + else: + return dialect.type_descriptor(Text()) + +def upgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column(u'tagmanifest', 'json_data') + op.add_column(u'tagmanifest', sa.Column('json_data', EngineLongText(), nullable=False)) + ### end Alembic commands ### + + +def downgrade(tables): + ### commands auto generated by Alembic - please adjust! ### + op.drop_column(u'tagmanifest', 'json_data') + op.add_column(u'tagmanifest', sa.Column('json_data', sa.Text(), nullable=False)) + ### end Alembic commands ###