# Can you upgrade Discourse seamlessly if there is a breaking db change?

**URL:** https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175
**Category:** Support
**Created:** [3 באפריל,‏ 2015,‏ 9:48pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175 "2015-04-03T21:48:59Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 6:22pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/1 "2015-04-03T18:22:53Z")

</div>

But what about migrations? Do they respect upgrades between new releases? How do you manage to solve the case when new release makes breaking changes in db?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3 באפריל,‏ 2015,‏ 8:58pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/2 "2015-04-03T20:58:31Z")

</div>

Can you explain you question, keeping in mind that each `rebuild` will run `db:migrate`

---

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 9:12pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/3 "2015-04-03T21:12:15Z")

</div>

If one of the docker container makes breaking changes in db how do they share the same db in production?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3 באפריל,‏ 2015,‏ 9:13pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/4 "2015-04-03T21:13:36Z")

</div>

I still do not understand your question, slowly, can you explain clearly what you are asking for … and first read this:

> <https://github.com/discourse/discourse_docker/blob/master/templates/web.template.yml#L135-L137>

---

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 9:22pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/5 "2015-04-03T21:22:16Z")

</div>

> [@Manually update Discourse and Docker image to latest](https://meta.discourse.org/t/manually-update-discourse-and-docker-image-to-latest/23325/17):
>
> If you want zero downtime, you must run 2 web containers and cycle them in and out using haproxy

So, one container in public and the second one is on stage. Let’s imagine that the second one goes with migration which makes breaking changes in db (for example, removes column). How do the first one will react on this?

---

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 9:23pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/6 "2015-04-03T21:23:47Z")

</div>

As far as I understand you, both of the containers will share the same db. Am I right?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3 באפריל,‏ 2015,‏ 9:25pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/7 "2015-04-03T21:25:57Z")

</div>

breaking db changes will always cause downtime we can not magic that away

---

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 9:31pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/8 "2015-04-03T21:31:05Z")

</div>

It’s possible by making them responsible for old code and some kind of convention, imho.

---

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 9:32pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/9 "2015-04-03T21:32:26Z")

</div>

Otherwise, people have to observe migrations that you have done.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [3 באפריל,‏ 2015,‏ 9:53pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/10 "2015-04-03T21:53:11Z")

</div>

I have no idea what you are proposing here and am having extreme issues following you.

**IF** we decide one day to rename the table `topics` to `amazing-topics` then old web servers running our old repo will break. Only way to keep them working under such conditions is to create a writable view during the migration that keeps backwards compat in place.

In general our migrations are backwards compat. **Rarely** they are not, when they are not there is a minor outage.

I am happy with you to slowly explain your technical recommendations but your one-liners here are not really helping me.

---

<div class="post-metadata">

### Author: ![skyeagle](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@skyeagle](https://meta.discourse.org/u/skyeagle)
#### Post date: [3 באפריל,‏ 2015,‏ 10:15pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/11 "2015-04-03T22:15:29Z")

</div>

> [@sam](#):
>
> Only way to keep them working under such conditions is to create a writable view during the migration that keeps backwards compat in place.
> 
> In general our migrations are backwards compat. Rarely they are not, when they are not there is a minor outage.

This is exactly what I’m talking about. And I’m happy that you follow this practice. Thank you.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [3 באפריל,‏ 2015,‏ 10:30pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/12 "2015-04-03T22:30:25Z")

</div>

Well… you could use a semantic versioning scheme for the schema versions:

- If the migration updates the major version, all workers must be taken down,
- if it updates the minor version, workers on the old version must be in read-only mode,
- and if only the patch version changes, workers can keep running throughout the migration.

If someone wants to maintain a huge Discourse cluster, they’ll know how to perform the upgrade, assuming that they have a custom tool that orchestrates all the `launcher`s on the machines involved…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [23 בספטמבר,‏ 2018,‏ 3:12pm UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/13 "2018-09-23T15:12:01Z")

</div>



---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [28 בספטמבר,‏ 2018,‏ 12:38am UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/14 "2018-09-28T00:38:45Z")

</div>

Our current practices are to always ensure all upgrades from direct previous versions never ship breaking scheme

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [28 בספטמבר,‏ 2018,‏ 12:39am UTC](https://meta.discourse.org/t/can-you-upgrade-discourse-seamlessly-if-there-is-a-breaking-db-change/27175/15 "2018-09-28T00:39:05Z")

</div>


