Switch Text to LongText for MySQL manifests
This commit is contained in:
parent
cb7ec2f239
commit
ddbe33e2ce
1 changed files with 47 additions and 0 deletions
|
@ -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 ###
|
Reference in a new issue