# Discourse appears to be broken with Postgres 10

**URL:** https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723
**Category:** Development
**Created:** [October 9, 2017, 11:28pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723 "2017-10-09T23:28:49Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [October 9, 2017, 11:28pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/1 "2017-10-09T23:28:49Z")

</div>

discourse-1.9.0.beta12~git20.14b1736c74-9.1.noarch

```plaintext
== Seed from /srv/www/vhosts/discourse/db/fixtures/003_post_action_types.rb
 - PostActionType {:id=>1, :name_key=>"bookmark", :is_flag=>false, :position=>1}
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "increment_by" does not exist
LINE 1: ...types_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_...
                                                             ^
: SELECT setval('public.post_action_types_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_by FROM public.post_action_types_id_seq), (SELECT min_value FROM public.post_action_types_id_seq)) FROM "post_action_types"), false)
(eval):1:in `block (2 levels) in run_file'
/srv/www/vhosts/discourse/lib/tasks/db.rake:26:in `block in <top (required)>'
/usr/bin/rake.ruby2.4:22:in `load'
/usr/bin/rake.ruby2.4:22:in `<top (required)>'
/usr/bin/bundle.ruby2.4:22:in `load'
/usr/bin/bundle.ruby2.4:22:in `<main>'
PG::UndefinedColumn: ERROR: column "increment_by" does not exist
LINE 1: ...types_id_seq', (SELECT GREATEST(MAX("id")+(SELECT increment_...
                                                             ^
(eval):1:in `block (2 levels) in run_file'
/srv/www/vhosts/discourse/lib/tasks/db.rake:26:in `block in <top (required)>'
/usr/bin/rake.ruby2.4:22:in `load'
/usr/bin/rake.ruby2.4:22:in `<top (required)>'
/usr/bin/bundle.ruby2.4:22:in `load'
/usr/bin/bundle.ruby2.4:22:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

```

---

<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: [October 9, 2017, 11:51pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/2 "2017-10-09T23:51:23Z")

</div>

We are not seeing it in our [official install](https://meta.discourse.org/t/142537?silent=true), my guess is that this is somehow postgres 10 related.

What version of pg are you using?

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [October 9, 2017, 11:52pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/3 "2017-10-09T23:52:40Z")

</div>

oh right good point … i did switch to postgresql 10 after 1.9.0.beta12~git0.7ed522c890-7.1.

---

<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: [October 10, 2017, 12:03am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/4 "2017-10-10T00:03:07Z")

</div>

Well, we have not yet done the work to get Discourse to work with PG 10, we will get there.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [October 10, 2017, 12:11am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/5 "2017-10-10T00:11:40Z")

</div>

maybe the code should be guarded with somethin like

```plaintext
@conn = PG.connect(args)
if @conn.server_version >= 100000
  # error out and exit cleanly
end

```

And maybe it should be documented that pg10 isnt supported yet.

---

<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: [October 10, 2017, 12:44am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/6 "2017-10-10T00:44:53Z")

</div>

I would much rather spending the time getting Discourse to work properly on PG 10

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [October 10, 2017, 1:24am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/7 "2017-10-10T01:24:56Z")

</div>

sure. 🙂

I just remembered that it was really easy to check the pg version (used it in my script for the last pg security update).

if you need any PG 10 testers feel free to poke me. I was beta testing pg 10 on a less important host for a while and jumped mg production machine on the day after the release.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [October 11, 2017, 10:57am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/8 "2017-10-11T10:57:55Z")

</div>

this could even be a activerecord problem no?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 12, 2017, 12:56am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/9 "2017-10-12T00:56:16Z")

</div>

I believe @tgxworld was going to take a look.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [November 2, 2017, 12:49am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/10 "2017-11-02T00:49:47Z")

</div>

opened an issue here: [postgresql 10 breaks sequence handling · Issue #122 · mbleigh/seed-fu · GitHub](https://github.com/mbleigh/seed-fu/issues/122)

---

<div class="post-metadata">

### Author: ![ryanbigg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ryanbigg/32/103153_2.png) [@ryanbigg](https://meta.discourse.org/u/ryanbigg)
#### Post date: [November 2, 2017, 2:12am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/11 "2017-11-02T02:12:52Z")

</div>

There was a similar issue with the sequel gem recently, which was fixed by this commit: [Make Database#reset\_primary\_key\_sequence work on PostgreSQL 10+ · jeremyevans/sequel@8370980 · GitHub](http://github.com/jeremyevans/sequel/commit/8370980b12f59d5439344d4de89d4552f05a3d13). Likely the same kind of fix would need to be done on seed-fu.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [November 2, 2017, 2:42pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/12 "2017-11-02T14:42:36Z")

</div>

there is already PR for seed-fu pending [Support PostgreSQL 10 by ppworks · Pull Request #121 · mbleigh/seed-fu · GitHub](https://github.com/mbleigh/seed-fu/pull/121)

Just tested it here and the rake tasks complete again.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 2, 2017, 8:37pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/13 "2017-11-02T20:37:17Z")

</div>

Good to know, can we merge in those updated dependencies @tgxworld?

---

<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: [November 2, 2017, 10:19pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/14 "2017-11-02T22:19:47Z")

</div>

It is not merged in yet, I actually think we should just pull in the seed fu functionality we need into core, this keeps on breaking rails upgrade after rails upgrade and now after pg upgrades, there is like 50 lines of code we care about in this gem, maybe less.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 3, 2017, 12:15am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/15 "2017-11-03T00:15:04Z")

</div>

Up to you, I would prefer to do the simple / less work thing in this case though.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [November 24, 2017, 3:55pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/16 "2017-11-24T15:55:01Z")

</div>

JFYI: [postgresql 10 breaks sequence handling · Issue #122 · mbleigh/seed-fu · GitHub](https://github.com/mbleigh/seed-fu/issues/122#issuecomment-346783243)

bumping seed-fu would allow you to run on postgresql 10. then you could also remove the warning again. (it was added in the OSX docs e.g.)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [November 27, 2017, 3:57am UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/17 "2017-11-27T03:57:25Z")

</div>

Seed-fu has been updated with support for PG10

[https://github.com/discourse/discourse/commit/c8157f6b0764f616c394b19bbccad843c859b201](https://github.com/discourse/discourse/commit/c8157f6b0764f616c394b19bbccad843c859b201)

We’ve still yet to test Discourse fully with PG 10 but that will be happening soon.

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [November 27, 2017, 1:36pm UTC](https://meta.discourse.org/t/discourse-appears-to-be-broken-with-postgres-10/71723/18 "2017-11-27T13:36:43Z")

</div>

From my experience i can tell you … It works fine 🙂

But sure more testing is better.
