# 容器中如何处理 PostgreSQL 升级？

**URL:** <https://meta.discourse.org/t/how-are-postgresql-upgrades-handled-in-the-container/113952>\
**Category:** Self-hosting\
**Tags:** hosting\
**Created:** [2019年四月10日 11:06 UTC](https://meta.discourse.org/t/how-are-postgresql-upgrades-handled-in-the-container/113952 "2019-04-10T11:06:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BjornW](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bjornw/32/137412_2.png) [@BjornW](https://meta.discourse.org/u/BjornW)\
**Post date:** [2019年四月10日 11:06 UTC](https://meta.discourse.org/t/how-are-postgresql-upgrades-handled-in-the-container/113952/1 "2019-04-10T11:06:14Z")

</div>

在使用官方 Docker 容器自托管 Discourse 时，底层数据库（以及 Ruby on Rails）的更新或升级将如何处理？

我刚开始接触 PostgreSQL，但我了解到它的一些过去升级过程曾相当复杂。

---

<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:** [2019年八月15日 21:59 UTC](https://meta.discourse.org/t/how-are-postgresql-upgrades-handled-in-the-container/113952/2 "2019-08-15T21:59:43Z")

</div>

Ruby 通过为容器提供新的基础镜像进行更新。

Postgres 的升级更为复杂，但在需要时，数据库会先进行备份，转换为新格式，然后进行迁移。这通常都能成功。他们通常会跳过每隔一次的 Postgres 升级，因此下一次升级还要过一段时间。（如果你真的很关心，可以查看 `discourse_docker` 仓库中 `templates` 目录下的 postgres 模板。
