# 恢复时出现问题：“mirror\_topic\_timers\_topic\_id”函数已存在且参数类型相同

**URL:** <https://meta.discourse.org/t/problem-with-restore-function-mirror-topic-timers-topic-id-already-exists-with-same-argument-types/383176>\
**Category:** Bug\
**Created:** [2025年九月18日 19:03 UTC](https://meta.discourse.org/t/problem-with-restore-function-mirror-topic-timers-topic-id-already-exists-with-same-argument-types/383176 "2025-09-18T19:03:31Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2025年九月18日 19:03 UTC](https://meta.discourse.org/t/problem-with-restore-function-mirror-topic-timers-topic-id-already-exists-with-same-argument-types/383176/1 "2025-09-18T19:03:31Z")

</div>

我正在尝试将生产数据库从 `04dbc622ab1e0197d16703ba47cf005ec93697ee` 恢复到开发站点 `f608e0cd7e7d4785b3ecb401999cfb837cfbe783`

我遇到了这些错误：

```plaintext
数据库迁移失败。 [90/9045]
忽略 db/schema_cache.yml，因为它已过期。当前架构版本是 20250724012518，但架构缓存文件中的版本是 20250916082012。
rake 中止！
StandardError: 发生错误，此迁移及之后的所有迁移都已取消: (StandardError)

PG::DuplicateFunction: 错误： 函数 “mirror_topic_timers_topic_id” 已存在且参数类型相同
/home/pfaffman/src/discourse-repos/discourse/lib/migration/safe_migrate.rb:107:in `async_exec'
/home/pfaffman/src/discourse-repos/discourse/db/migrate/20250902014817_add_timerable_id_to_topic_timer.rb:15:in `up'
/home/pfaffman/src/discourse-repos/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `block in exec_migration'
/home/pfaffman/src/discourse-repos/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/home/pfaffman/src/discourse-repos/discourse/lib/migration/safe_migrate.rb:28:in `migrate'
/home/pfaffman/src/discourse-repos/discourse/lib/migration/safe_migrate.rb:53:in `migrate'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/db.rake:267:in `block (2 levels) in <main>'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:53:in `block in synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:34:in `synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/db.rake:242:in `block in <main>'

导致：
ActiveRecord::StatementInvalid: PG::DuplicateFunction: 错误： 函数 “mirror_topic_timers_topic_id” 已存在且参数类型相同 (ActiveRecord::S
ntatementInvalid)
/home/pfaffman/src/discourse-repos/discourse/lib/migration/safe_migrate.rb:107:in `async_exec'
/home/pfaffman/src/discourse-repos/discourse/db/migrate/20250902014817_add_timerable_id_to_topic_timer.rb:15:in `up'
/home/pfaffman/src/discourse-repos/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `block in exec_migration'
/home/pfaffman/src/discourse-repos/discourse/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/home/pfaffman/src/discourse-repos/discourse/lib/migration/safe_migrate.rb:28:in `migrate'
/home/pfaffman/src/discourse-repos/discourse/lib/migration/safe_migrate.rb:53:in `migrate'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/db.rake:267:in `block (2 levels) in <main>'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:53:in `block in synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:49:in `synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/distributed_mutex.rb:34:in `synchronize'
/home/pfaffman/src/discourse-repos/discourse/lib/tasks/db.rake:242:in `block in <main>'

```

我认为这可能与此有关：

> <https://github.com/discourse/discourse/pull/34667>
>
> To prepare for the introduction of \`CategoryDefaultTimer\`, which allows posts cr…eated in certain categories to have a default TopicTimer, we need to rename the \`topic\_id\` column to \`timerable\_id\`.

---

_[View the full topic](https://meta.discourse.org/t/problem-with-restore-function-mirror-topic-timers-topic-id-already-exists-with-same-argument-types/383176)._
