-
setup postgres database with the following schema
sudo su - postgres createuser -P relieve createdb -O relieve relieve note: update pg_hba.conf from local all all peer to local all all md5 psql -U relieve -d relieve
-
export port and datatabase environment variable
export PORT=4000 export DATABASE_URL=postgres://relieve:relieve@localhost/relieve
-
Build & run it
go install relieve
-
start testing endpoint
Create app with custom buildpack
heroku apps:create relieve-endpoint -b https://github.com/kr/heroku-buildpack-go.git
echo 'web: relieve' > Procfile
heroku addons:add heroku-postgresql
Push code to heroku
godep save
git add . && git commit -m "deploy to heroku"
git push heroku master
Make sure godep installed
go get github.com/tools/godep
Update heroku database
heroku pg:psql
and create the following schema
Change column type text
to integer
ALTER TABLE psikologs
ALTER COLUMN psikolog_wisdom TYPE integer USING cast(psikolog_wisdom as int);
Add default to existing columns
ALTER TABLE posts
ALTER COLUMN post_date SET DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE psikologs
ALTER COLUMN psikolog_wisdom SET DEFAULT 0;
ALTER TABLE posts
ALTER COLUMN post_report_count SET DEFAULT 0;
ALTER TABLE comments
ALTER COLUMN comment_date SET DEFAULT CURRENT_TIMESTAMP;