# Error deploy first time on server with postgresql database

**URL:** <https://forum.foodcoops.net/t/error-deploy-first-time-on-server-with-postgresql-database/287>\
**Category:** Foodsoft Developement\
**Created:** [April 28, 2016, 8:04pm UTC](https://forum.foodcoops.net/t/error-deploy-first-time-on-server-with-postgresql-database/287 "2016-04-28T20:04:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon](https://forum.foodcoops.net/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@simon](https://forum.foodcoops.net/u/simon)\
**Post date:** [April 28, 2016, 8:04pm UTC](https://forum.foodcoops.net/t/error-deploy-first-time-on-server-with-postgresql-database/287/1 "2016-04-28T20:04:37Z")

</div>

Hi I wanted to deploy the app (first time ) and created a database on the server. Then I ran bundle exec cap production deploy. I am still in my own repository, but except the addition to the Gemfile “gem ‘pg’” its basically like the HEAD of master (deploy:check works).

I get the following error when db:migrate is run:

Exception while executing as simon@xxxxxxx: Exception while executing as simon@xxxxxxx: rake exit status: 1  
rake stdout: == 1 CreateUsers: migrating ===================================================  
– create\_table(:users)  
 → 0.0039s  
– add\_index(:users, :nick, {:unique=\>true})  
 → 0.0022s  
– add\_index(:users, :email, {:unique=\>true})  
 → 0.0018s  
Creating user admin with password ‘secret’…  
rake stderr: rake aborted!  
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR: relation “settings” does not exist  
LINE 5: WHERE a.attrelid = ‘“settings”’::regclass  
^  
: SELECT a.attname, format\_type(a.atttypid, a.atttypmod),  
pg\_get\_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod  
FROM pg\_attribute a LEFT JOIN pg\_attrdef d  
ON a.attrelid = d.adrelid AND a.attnum = d.adnum  
WHERE a.attrelid = ‘“settings”’::regclass  
AND a.attnum \> 0 AND NOT a.attisdropped  
ORDER BY a.attnum

What is the correct workflow when deploying the first time?

- I tried deploy cap production deploy (failed)
- Then created db on server
- Run deploy production again (failed again, s. above)
- Then on server: ENV bundle exec rake db:create (but wont work as db already exist)

Sorry for the newie question, but I after having spent quite some time I hope someone can make me understand… 🙂

---

<div class="post-metadata">

**Author:** ![wvengen](https://forum.foodcoops.net/user_avatar/forum.foodcoops.net/wvengen/32/4_2.png) [@wvengen](https://forum.foodcoops.net/u/wvengen)\
**Post date:** [April 29, 2016, 11:57am UTC](https://forum.foodcoops.net/t/error-deploy-first-time-on-server-with-postgresql-database/287/2 "2016-04-29T11:57:54Z")

</div>

Hi Simon,

Deployment is still a bit under-documented (as you may have understood  
from the docs/wiki).  
This is the process for updating an existing installation. At the  
moment, you may need to load the database schema first as well. So after  
you’ve created the database, load the schema, and seed it (so that you  
can login as admin).  
RAILS\_ENV=production rake db:setup will do all of this when you run it  
on the server. Perhaps you need to drop the database first to start from  
scratch.

- Willem

---

<div class="post-metadata">

**Author:** ![simon](https://forum.foodcoops.net/letter_avatar_proxy/v4/letter/s/f07891/32.png) [@simon](https://forum.foodcoops.net/u/simon)\
**Post date:** [April 29, 2016, 1:50pm UTC](https://forum.foodcoops.net/t/error-deploy-first-time-on-server-with-postgresql-database/287/3 "2016-04-29T13:50:46Z")

</div>

Ah, oh man…

ok I db:setup worked perfectly, now I ve got the db incl. tables and was able to deploy. Hope I can get it running with apache2 now. Finally…

Thanks!!!
