Can't restore to new site: "first_unread_topic_for" already exists with same argument types


(Jay Pfaffman) #1

I’m trying to restore a backup to a new site. It’s failed with this error:

[2017-05-25 21:35:33] EXCEPTION: An error has occurred, this and all later migrations canceled:

PG::DuplicateFunction: ERROR:  function "first_unread_topic_for" already exists with same argument types
:     CREATE FUNCTION first_unread_topic_for(user_id int)
    RETURNS timestamp AS
    $$
    SELECT COALESCE(first_topic_unread_at, 'epoch'::timestamp)
    FROM users u
    JOIN user_stats ON user_id = u.id
    WHERE u.id = $1
    $$
    LANGUAGE SQL STABLE

(Jeff Atwood) #2

Is this a new change from you @sam?


(Jay Pfaffman) #3

Looks like it. It’s in this commit.


(Sam Saffron) #4

Its a backup quirk, we don’t move the function out of the schema.

Fixed per: