# \[SOLVED\] Initial mattermost setup - psql errors: relation X does not exist

**URL:** <https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653>\
**Category:** Troubleshooting\
**Created:** [June 7, 2016, 4:38pm UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653 "2016-06-07T16:38:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![crucidal](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@crucidal](https://forum.mattermost.com/u/crucidal)\
**Post date:** [June 7, 2016, 4:38pm UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653/1 "2016-06-07T16:38:00Z")

</div>

Hi,

I’m running into some trouble while trying to set-up a mattermost server with Gitlab oauth.  
Gitlab runs on a bare system, mattermost and psql each in their own docker containers.

I’m getting the exact same errors as shown here: [https://github.com/mattermost/platform/issues/2478](https://github.com/mattermost/platform/issues/2478) However, the `solution´ does not seem to work for me.

tried mattermost 3.0.3 in combination with gitlab 8.8 and psql 9.5 and 9.6.

How can I continue debugging this in order to make it work?

kind regards,  
Chris

## **Relevant parts of mattermost dockerfile:** `RUN wget https://releases.mattermost.com/3.0.3/mattermost-team-3.0.3-linux-amd64.tar.gz \` `ENTRYPOINT ["/opt/mattermost/bin/platform","-config=/opt/mattermost/config/config.json"]`

**obfuscated config.json**  
`{ "ServiceSettings": { "ListenAddress": ":8065", "MaximumLoginAttempts": 10, "SegmentDeveloperKey": "", "GoogleDeveloperKey": "", "EnableOAuthServiceProvider": false, "EnableIncomingWebhooks": false, "EnableOutgoingWebhooks": false, "EnableCommands": false, "EnableOnlyAdminIntegrations": true, "EnablePostUsernameOverride": false, "EnablePostIconOverride": false, "EnableTesting": false, "EnableDeveloper": false, "EnableSecurityFixAlert": true, "EnableInsecureOutgoingConnections": false, "EnableMultifactorAuthentication": false, "AllowCorsFrom": "", "SessionLengthWebInDays": 30, "SessionLengthMobileInDays": 30, "SessionLengthSSOInDays": 30, "SessionCacheInMinutes": 10, "WebsocketSecurePort": 443, "WebsocketPort": 80, "WebserverMode": "regular" }, "TeamSettings": { "SiteName": "Mattermost@mycompany", "MaxUsersPerTeam": 50, "EnableTeamCreation": false, "EnableUserCreation": true, "EnableOpenServer": false, "RestrictCreationToDomains": "", "RestrictTeamNames": true, "EnableCustomBrand": false, "CustomBrandText": "", "RestrictDirectMessage": "any" }, "SqlSettings": { "DriverName": "postgres", "DataSource": "postgres://user:pass@1234.mydomain:2288/mattermost?sslmode=disable\u0026connect_timeout=10", "DataSourceReplicas": [], "MaxIdleConns": 10, "MaxOpenConns": 10, "Trace": false, "AtRestEncryptKey": "..." }, "LogSettings": { "EnableConsole": true, "ConsoleLevel": "DEBUG", "EnableFile": true, "FileLevel": "INFO", "FileFormat": "", "FileLocation": "" }, "FileSettings": { "DriverName": "local", "Directory": "./data/", "EnablePublicLink": false, "PublicLinkSalt": "...", "ThumbnailWidth": 120, "ThumbnailHeight": 100, "PreviewWidth": 1024, "PreviewHeight": 0, "ProfileWidth": 128, "ProfileHeight": 128, "InitialFont": "luximbi.ttf", "AmazonS3AccessKeyId": "", "AmazonS3SecretAccessKey": "", "AmazonS3Bucket": "", "AmazonS3Region": "", "AmazonS3Endpoint": "", "AmazonS3BucketEndpoint": "", "AmazonS3LocationConstraint": false, "AmazonS3LowercaseBucket": false }, "EmailSettings": { "EnableSignUpWithEmail": false, "EnableSignInWithEmail": false, "EnableSignInWithUsername": true, "SendEmailNotifications": false, "RequireEmailVerification": false, "FeedbackName": "", "FeedbackEmail": "", "SMTPUsername": "", "SMTPPassword": "", "SMTPServer": "", "SMTPPort": "", "ConnectionSecurity": "", "InviteSalt": "...", "PasswordResetSalt": "...", "SendPushNotifications": false, "PushNotificationServer": "", "PushNotificationContents": "generic" }, "RateLimitSettings": { "EnableRateLimiter": true, "PerSec": 10, "MemoryStoreSize": 10000, "VaryByRemoteAddr": true, "VaryByHeader": "" }, "PrivacySettings": { "ShowEmailAddress": true, "ShowFullName": true }, "SupportSettings": { "TermsOfServiceLink": "https://about.mattermost.com/default-terms/", "PrivacyPolicyLink": "https://about.mattermost.com/default-privacy-policy/", "AboutLink": "https://about.mattermost.com/default-about/", "HelpLink": "https://about.mattermost.com/default-help/", "ReportAProblemLink": "https://about.mattermost.com/default-report-problem/", "SupportEmail": "..." }, "GitLabSettings": { "Enable": true, "Secret": "...", "Id": "...", "Scope": "", "AuthEndpoint": "https://gitlab-t.mydomain/oauth/authorize", "TokenEndpoint": "https://gitlab-t.mydomain/oauth/token", "UserApiEndpoint": "https://gitlab-t.mydomain/api/v3/user" }, "GoogleSettings": { "Enable": false, "Secret": "", "Id": "", "Scope": "", "AuthEndpoint": "", "TokenEndpoint": "", "UserApiEndpoint": "" }, "LdapSettings": { "Enable": false, "LdapServer": "", "LdapPort": 389, "ConnectionSecurity": "", "BaseDN": "", "BindUsername": "", "BindPassword": "", "UserFilter": "", "FirstNameAttribute": "", "LastNameAttribute": "", "EmailAttribute": "", "UsernameAttribute": "", "NicknameAttribute": "", "IdAttribute": "", "SkipCertificateVerification": false, "QueryTimeout": 60, "LoginFieldName": "" }, "ComplianceSettings": { "Enable": false, "Directory": "./data/", "EnableDaily": false } }`

**psql container**  
see [https://github.com/docker-library/postgres.git](https://github.com/docker-library/postgres.git)  
The only addition I made was to create the user/database + privileges which are being used in the config.json from mattermost.

---

<div class="post-metadata">

**Author:** ![jwilander](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jwilander/32/8440_2.png) [@jwilander](https://forum.mattermost.com/u/jwilander)\
**Post date:** [June 15, 2016, 12:25pm UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653/2 "2016-06-15T12:25:16Z")

</div>

Hi @crucidal,

Can you provide the full errors that you get? Or are you missing the ‘Type’ column for the ‘Preference’ table just like in that GitHub issue?

---

<div class="post-metadata">

**Author:** ![aetherical](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/aetherical/32/857_2.png) [@aetherical](https://forum.mattermost.com/u/aetherical)\
**Post date:** [August 8, 2016, 9:59pm UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653/3 "2016-08-08T21:59:55Z")

</div>

I am getting the same errors. It appears that the database is not being created?

I am using mattermost-docker:

```
git clone https://github.com/mattermost/mattermost-docker
cd mattermost-docker
docker-compose build
docker-compose up -d
docker logs mattermost_db_1

```

I am able to reproduce it on more than one host. 😕

---

<div class="post-metadata">

**Author:** ![crucidal](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@crucidal](https://forum.mattermost.com/u/crucidal)\
**Post date:** [August 22, 2016, 9:50am UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653/4 "2016-08-22T09:50:33Z")

</div>

Hi Jwil,

Sorry for the fact that I didn’t respond in such a long time!  
The issue is still relevant for me so here’s the full errors that I’m seeing:

> **error logs**
>
> ERROR: relation “systems” does not exist at character 19  
> STATEMENT: SELECT Value FROM Systems WHERE Name='Version’  
> ERROR: relation “idx\_teams\_name” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_teams\_invite\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_teammembers\_team\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_teammembers\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_channels\_team\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_channels\_name” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_channelmembers\_channel\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_channelmembers\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_posts\_update\_at” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_posts\_create\_at” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_posts\_channel\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_posts\_root\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_posts\_message\_txt” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_posts\_hashtags\_txt” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_users\_email” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_audits\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_sessions\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_sessions\_token” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_oauthapps\_creator\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_oauthaccessdata\_client\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_oauthaccessdata\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_oauthaccessdata\_refresh\_token” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_oauthauthdata\_client\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_incoming\_webhook\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_incoming\_webhook\_team\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_outgoing\_webhook\_team\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_command\_team\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_preferences\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_preferences\_category” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_preferences\_name” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_password\_recovery\_code” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_status\_user\_id” does not exist  
> STATEMENT: SELECT $1::regclass  
> ERROR: relation “idx\_status\_status” does not exist  
> STATEMENT: SELECT $1::regclass

Currently I’m on mattermost version 3.3.0.  
The fact that I’m using Oauth does not seem to make a difference. (the errors also occur when I start a completely new mattermost instance + new DB with oauth disabled)

It seems like mattermost is not properly populating the empty database and tries to query for non-existing relations.  
The question is: How do I fix this? 🙂

edit: The preview properly shows my errors embedded in a “details” section but the actual post does not.  
Sorry if I messed up :o

Kind Regards,  
Chris

---

<div class="post-metadata">

**Author:** ![jwilander](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jwilander/32/8440_2.png) [@jwilander](https://forum.mattermost.com/u/jwilander)\
**Post date:** [August 29, 2016, 5:48pm UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653/5 "2016-08-29T17:48:18Z")

</div>

Have you tried following the steps in the [install guide](https://docs.mattermost.com/install/prod-ubuntu.html) (this is for Ubuntu but we have other install guides in the sidebar)? I just ran through them and they worked for me when setting up a postrgres database.

The only minor issue I had was setting:  
`local all all peer`  
to:  
`local all all md5`  
under the local connections section in my /etc/postgresql/9.3/main/pg\_hba.conf file, since I was running the postgres box off my localhost.

---

<div class="post-metadata">

**Author:** ![stephane-klein](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/stephane-klein/32/975_2.png) [@stephane-klein](https://forum.mattermost.com/u/stephane-klein)\
**Post date:** [October 30, 2016, 8:38pm UTC](https://forum.mattermost.com/t/solved-initial-mattermost-setup-psql-errors-relation-x-does-not-exist/1653/6 "2016-10-30T20:38:57Z")

</div>

Same issue here? [[Solved] PostgreSQL error after Mattermost upgrade from 3.2.0 to 3.4.0: some relation does not exist](http://forum.mattermost.com/t/postgresql-error-after-mattermost-upgrade-from-3-2-0-to-3-4-0-some-relation-does-not-exist/2428/3?u=stephane-klein)
