2016-06-30 39 views
0

我正試圖在Heroku上部署一個使用Postgressql的小Dancer2應用程序。 到目前爲止,我試圖接近: a)我輸入heroku addons:add heroku-postgresql手工創建的所有表格,並將權限授予我在我的heroku db連接設置中找到的默認所有者。然後我將以下連接設置添加到我的config.yml文件中:Heroku上的Postgesql的Dancer2應用程序

DBIC: 
    d1ofgde: 
     dsn: 'dbi:Pg:dbname=d1ofgde' 
     user: 'ygcexhxtprm' 
     password: 'izU2xTVDfd5T5Byy4M4Xhk' 
     host: 'ec2-54-244-50-186.compute-1.amazonaws.com' 
     port: 5432 
     options: 
     RaiseError: 1 
     PrintError: 1 
     schema_class: 'My::Schema 

失敗。

B)我試圖把我的本地的Postgres數據庫在Heroku上使用這個命令:

PGUSER=test PGPASSWORD=test heroku pg:push mytestdb DATABASE_URL postgres://ygcexmzlhxtprm:[email protected].com:5432/d1ofgdng49tf0e --app lit-mesa-10053 

推手的錯誤:

:pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of extension plpgsql 
    Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language 

但是,當我在我的Heroku Postgres的記錄,我看到裏面的表格。

在這兩種情況下,我在我的config.yml中爲我的連接設置使用了相同的結構。並得到了相同的錯誤消息:

2016-06-30T10:01:59.918775+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-mesa-10053.herokuapp.com request_id=99195ea6-fb7e-488c-93e8-2b7b5e306432 fwd="89.122.156.100" dyno= connect= service= status=503 bytes= 
2016-06-30T10:02:00.403773+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-mesa-10053.herokuapp.com request_id=dae4956e-954c-498b-8a32-e8ef8dc01c43 fwd="89.122.156.100" dyno= connect= service= status=503 bytes= 
2016-06-30T10:12:07.295999+00:00 heroku[web.1]: State changed from crashed to starting 
2016-06-30T10:12:14.677356+00:00 app[web.1]: Error while loading /app/app.psgi: The schema mytestdb is not configured at /app/local/lib/perl5/DBICx/Sugar.pm line 52, <DATA> line 1. 
2016-06-30T10:12:14.677382+00:00 app[web.1]: Compilation failed in require at /app/app.psgi line 11, <DATA> line 1. 
2016-06-30T10:12:15.886678+00:00 heroku[web.1]: Process exited with status 255 
2016-06-30T10:12:20.228220+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-mesa-10053.herokuapp.com request_id=36a8291d-fce1-485e-979c-986db9cbf9b7 fwd="89.122.156.100" dyno= connect= service= status=503 bytes= 

回答

0

所以,我解決我的錯誤與此代碼:在myapp.pm 我加入這行:

my $env_url = $ENV{MYAPP_DB_DSN}; 
    my $env_user = $ENV{MYAPP_DB_USERNAME}; 
    my $env_password = $ENV{MYAPP_DB_PASSWORD}; 
my $schema = My::Schema->connect("$env_url;user=$env_user;password=$env_password"); 
heroku config:set

然後我給值

MyAPP_DB_DSN='dbi:Pg:dbname=mydb; host=myherokuhost'; port=5432' 
MYAPP_DB_USERNAME=myusername 
MYAPP_DB_PASSWORD=mypass 

現在有效