Added postgresql support.

This commit is contained in:
Martin Edenhofer 2016-01-20 02:00:02 +01:00
parent 9b7b5f0069
commit a2b68280b9

View file

@ -642,6 +642,7 @@ module Import::OTRS
ticket = Ticket.new(ticket_new) ticket = Ticket.new(ticket_new)
ticket.id = ticket_new[:id] ticket.id = ticket_new[:id]
ticket.save ticket.save
_reset_pk('tickets')
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
log "Ticket #{ticket_new[:id]} is handled by another thead, skipping." log "Ticket #{ticket_new[:id]} is handled by another thead, skipping."
next next
@ -723,6 +724,7 @@ module Import::OTRS
article_object = Ticket::Article.new(article_new) article_object = Ticket::Article.new(article_new)
article_object.id = article_new[:id] article_object.id = article_new[:id]
article_object.save article_object.save
_reset_pk('ticket_articles')
rescue ActiveRecord::RecordNotUnique rescue ActiveRecord::RecordNotUnique
log "Ticket #{ticket_new[:id]} (article #{article_new[:id]}) is handled by another thead, skipping." log "Ticket #{ticket_new[:id]} (article #{article_new[:id]}) is handled by another thead, skipping."
next next
@ -930,6 +932,7 @@ module Import::OTRS
state = Ticket::State.new(state_new) state = Ticket::State.new(state_new)
state.id = state_new[:id] state.id = state_new[:id]
state.save state.save
_reset_pk('ticket_states')
end end
} }
end end
@ -971,6 +974,7 @@ module Import::OTRS
priority = Ticket::Priority.new(priority_new) priority = Ticket::Priority.new(priority_new)
priority.id = priority_new[:id] priority.id = priority_new[:id]
priority.save priority.save
_reset_pk('ticket_priorities')
end end
} }
end end
@ -1011,6 +1015,7 @@ module Import::OTRS
group = Group.new(group_new) group = Group.new(group_new)
group.id = group_new[:id] group.id = group_new[:id]
group.save group.save
_reset_pk('groups')
end end
} }
end end
@ -1084,6 +1089,7 @@ module Import::OTRS
user = User.new(user_new) user = User.new(user_new)
user.id = user_new[:id] user.id = user_new[:id]
user.save user.save
_reset_pk('users')
end end
} }
end end
@ -1232,6 +1238,7 @@ module Import::OTRS
log "add User.find(#{user_new[:id]})" log "add User.find(#{user_new[:id]})"
user = User.new(user_new) user = User.new(user_new)
user.save user.save
_reset_pk('users')
end end
} }
end end
@ -1283,6 +1290,7 @@ module Import::OTRS
organization = Organization.new(organization_new) organization = Organization.new(organization_new)
organization.id = organization_new[:id] organization.id = organization_new[:id]
organization.save organization.save
_reset_pk('organizations')
end end
} }
end end
@ -1383,6 +1391,12 @@ module Import::OTRS
} }
end end
# reset primary key sequences
def self._reset_pk(table)
return if ActiveRecord::Base.connection_config[:adapter] != 'postgresql'
ActiveRecord::Base.connection.reset_pk_sequence!(table)
end
# create customers for article # create customers for article
def self._article_based_customers(article) def self._article_based_customers(article)