Skip to content

Commit

Permalink
Fix tsvector generation for tickets as 'group' is a reserved word in …
Browse files Browse the repository at this point in the history
…prostgres. Renaming column
  • Loading branch information
Tschuppi81 committed Jul 25, 2023
1 parent 6d0129f commit 5709ff5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/onegov/search/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,16 @@
upgraded on the server. See :class:`onegov.core.upgrade.upgrade_task`.
"""
from onegov.core.upgrade import upgrade_task


@upgrade_task('rename tickets column group to group_name')
def rename_tickets_column_group_to_group_name(context):
# Renaming the column group to group_name as 'group' is a reserved word
# in postgres and reindexing fails while generating the tsvector string

if context.has_column('tickets', 'group'):
context.session.execute("""
ALTER TABLE tickets
RENAME COLUMN group to group_name;
""")
6 changes: 3 additions & 3 deletions src/onegov/ticket/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Ticket(Base, TimestampMixin, ORMSearchable):
subtitle = Column(Text, nullable=True)

#: the group this ticket belongs to. used to differentiate tickets
#: belonging to one specific handler (handler -> group -> title)
group = Column(Text, nullable=False)
#: belonging to one specific handler (handler -> group_name -> title)
group_name = Column(Text, nullable=False)

#: the name of the handler associated with this ticket, may be used to
#: create custom polymorphic subclasses of this class. See
Expand Down Expand Up @@ -115,7 +115,7 @@ def created(cls):
'number': {'type': 'text'},
'title': {'type': 'text'},
'subtitle': {'type': 'text'},
'group': {'type': 'text'},
'group_name': {'type': 'text'},
# properties cannot be added to search index
# 'ticket_email': {'type': 'keyword'},
# 'ticket_data': {'type': 'localized_html'},
Expand Down

0 comments on commit 5709ff5

Please sign in to comment.