db: use LONGTEXT for mysql in user_logs. Fixes #5385, problem with mysql rejecting
insert because of too long json data. - simple case of lots of users in user group can cause mysql to fail on insert
This commit is contained in:
parent
d42acbacb7
commit
f42a5ca66b
3 changed files with 54 additions and 3 deletions
|
|
@ -51,7 +51,7 @@ PYRAMID_SETTINGS = {}
|
|||
EXTENSIONS = {}
|
||||
|
||||
__version__ = ('.'.join((str(each) for each in VERSION[:3])))
|
||||
__dbversion__ = 80 # defines current db version for migrations
|
||||
__dbversion__ = 81 # defines current db version for migrations
|
||||
__platform__ = platform.system()
|
||||
__license__ = 'AGPLv3, and Commercial License'
|
||||
__author__ = 'RhodeCode GmbH'
|
||||
|
|
|
|||
50
rhodecode/lib/dbmigrate/versions/081_version_4_10_0.py
Normal file
50
rhodecode/lib/dbmigrate/versions/081_version_4_10_0.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import logging
|
||||
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.engine import reflection
|
||||
from sqlalchemy.dialects.mysql import LONGTEXT
|
||||
|
||||
from alembic.migration import MigrationContext
|
||||
from alembic.operations import Operations
|
||||
|
||||
from rhodecode.model import meta
|
||||
from rhodecode.lib.dbmigrate.versions import _reset_base, notify
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
"""
|
||||
Upgrade operations go here.
|
||||
Don't create your own engine; bind migrate_engine to your metadata
|
||||
"""
|
||||
_reset_base(migrate_engine)
|
||||
from rhodecode.lib.dbmigrate.schema import db_4_9_0_0
|
||||
|
||||
if migrate_engine.name in ['mysql']:
|
||||
|
||||
context = MigrationContext.configure(migrate_engine.connect())
|
||||
op = Operations(context)
|
||||
|
||||
user_log_table = db_4_9_0_0.UserLog.__table__
|
||||
with op.batch_alter_table(user_log_table.name) as batch_op:
|
||||
|
||||
action_data_json = user_log_table.columns.action_data_json
|
||||
user_data_json = user_log_table.columns.user_data_json
|
||||
|
||||
batch_op.alter_column(action_data_json.name, type_=LONGTEXT)
|
||||
batch_op.alter_column(user_data_json.name, type_=LONGTEXT)
|
||||
|
||||
# issue fixups
|
||||
fixups(db_4_9_0_0, meta.Session)
|
||||
|
||||
|
||||
def downgrade(migrate_engine):
|
||||
meta = MetaData()
|
||||
meta.bind = migrate_engine
|
||||
|
||||
|
||||
def fixups(models, _SESSION):
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -43,6 +43,7 @@ from sqlalchemy.orm import (
|
|||
from sqlalchemy.sql.expression import true
|
||||
from sqlalchemy.sql.functions import coalesce, count # noqa
|
||||
from sqlalchemy.exc import IntegrityError # noqa
|
||||
from sqlalchemy.dialects.mysql import LONGTEXT
|
||||
from beaker.cache import cache_region
|
||||
from zope.cachedescriptors.property import Lazy as LazyProperty
|
||||
|
||||
|
|
@ -1233,8 +1234,8 @@ class UserLog(Base, BaseModel):
|
|||
action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
|
||||
|
||||
version = Column("version", String(255), nullable=True, default=VERSION_1)
|
||||
user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
|
||||
action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
|
||||
user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=LONGTEXT()))))
|
||||
action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=LONGTEXT()))))
|
||||
|
||||
def __unicode__(self):
|
||||
return u"<%s('id:%s:%s')>" % (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue