##// END OF EJS Templates
db: use LONGTEXT for mysql in user_logs. Fixes #5385, problem with mysql rejecting...
ergo -
r2087:d69882dc default
parent child Browse files
Show More
@@ -0,0 +1,50 b''
1 import logging
2
3 from sqlalchemy import *
4 from sqlalchemy.engine import reflection
5 from sqlalchemy.dialects.mysql import LONGTEXT
6
7 from alembic.migration import MigrationContext
8 from alembic.operations import Operations
9
10 from rhodecode.model import meta
11 from rhodecode.lib.dbmigrate.versions import _reset_base, notify
12
13 log = logging.getLogger(__name__)
14
15
16 def upgrade(migrate_engine):
17 """
18 Upgrade operations go here.
19 Don't create your own engine; bind migrate_engine to your metadata
20 """
21 _reset_base(migrate_engine)
22 from rhodecode.lib.dbmigrate.schema import db_4_9_0_0
23
24 if migrate_engine.name in ['mysql']:
25
26 context = MigrationContext.configure(migrate_engine.connect())
27 op = Operations(context)
28
29 user_log_table = db_4_9_0_0.UserLog.__table__
30 with op.batch_alter_table(user_log_table.name) as batch_op:
31
32 action_data_json = user_log_table.columns.action_data_json
33 user_data_json = user_log_table.columns.user_data_json
34
35 batch_op.alter_column(action_data_json.name, type_=LONGTEXT)
36 batch_op.alter_column(user_data_json.name, type_=LONGTEXT)
37
38 # issue fixups
39 fixups(db_4_9_0_0, meta.Session)
40
41
42 def downgrade(migrate_engine):
43 meta = MetaData()
44 meta.bind = migrate_engine
45
46
47 def fixups(models, _SESSION):
48 pass
49
50
@@ -51,7 +51,7 b' PYRAMID_SETTINGS = {}'
51 EXTENSIONS = {}
51 EXTENSIONS = {}
52
52
53 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
53 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
54 __dbversion__ = 80 # defines current db version for migrations
54 __dbversion__ = 81 # defines current db version for migrations
55 __platform__ = platform.system()
55 __platform__ = platform.system()
56 __license__ = 'AGPLv3, and Commercial License'
56 __license__ = 'AGPLv3, and Commercial License'
57 __author__ = 'RhodeCode GmbH'
57 __author__ = 'RhodeCode GmbH'
@@ -43,6 +43,7 b' from sqlalchemy.orm import ('
43 from sqlalchemy.sql.expression import true
43 from sqlalchemy.sql.expression import true
44 from sqlalchemy.sql.functions import coalesce, count # noqa
44 from sqlalchemy.sql.functions import coalesce, count # noqa
45 from sqlalchemy.exc import IntegrityError # noqa
45 from sqlalchemy.exc import IntegrityError # noqa
46 from sqlalchemy.dialects.mysql import LONGTEXT
46 from beaker.cache import cache_region
47 from beaker.cache import cache_region
47 from zope.cachedescriptors.property import Lazy as LazyProperty
48 from zope.cachedescriptors.property import Lazy as LazyProperty
48
49
@@ -1233,8 +1234,8 b' class UserLog(Base, BaseModel):'
1233 action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
1234 action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None)
1234
1235
1235 version = Column("version", String(255), nullable=True, default=VERSION_1)
1236 version = Column("version", String(255), nullable=True, default=VERSION_1)
1236 user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1237 user_data = Column('user_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=LONGTEXT()))))
1237 action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=UnicodeText(16384)))))
1238 action_data = Column('action_data_json', MutationObj.as_mutable(JsonType(dialect_map=dict(mysql=LONGTEXT()))))
1238
1239
1239 def __unicode__(self):
1240 def __unicode__(self):
1240 return u"<%s('id:%s:%s')>" % (
1241 return u"<%s('id:%s:%s')>" % (
General Comments 0
You need to be logged in to leave comments. Login now