Heroku Deployment Issues with Postgres and Sequelize - postgresql

I am trying to deploy my app to Heroku. It works perfectly fine when run locally. From the moment I deployed it (deploying through github integration) I received the generic Application Error screen. Below are my heroku logs. These actually run three times but there was no point in me posting the same thing three times. They always end with:
2017-05-02T14:59:26.033702+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-crag-40902.herokuapp.com request_id=6b64883e-9697-4d58-84d9-2f173d5b4cb1 fwd="70.
54.76.222" dyno= connect= service= status=503 bytes= protocol=https
2017-05-02T14:59:27.425435+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-crag-40902.herokuapp.com request_id=d3719d8f-4670-4621-a044-a511ee6884
10 fwd="70.54.76.222" dyno= connect= service= status=503 bytes= protocol=https
This will print 2 to 4 times after each consecutive error screen. The first error is regarding the .env files not running and the second is trying to connect to sequelize. My primary focus is sorting out the .env because if that is sorted out, at least the app will show my app will be visible.
.env error:
{ Error: ENOENT: no such file or directory, open '.env'
2017-05-02T16:09:39.622865+00:00 app[web.1]: at Error (native)
2017-05-02T16:09:39.622866+00:00 app[web.1]: at Object.fs.openSync (fs.js:641:18)
2017-05-02T16:09:39.622867+00:00 app[web.1]: at Object.fs.readFileSync (fs.js:509:33)
2017-05-02T16:09:39.622867+00:00 app[web.1]: at Object.config (/app/node_modules/dotenv/lib/main.js:30:37)
2017-05-02T16:09:39.622868+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:3:19)
2017-05-02T16:09:39.622869+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-05-02T16:09:39.622869+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-05-02T16:09:39.622870+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-05-02T16:09:39.622871+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-05-02T16:09:39.622871+00:00 app[web.1]: at Function.Module._load (module.js:438:3) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
2017-05-02T16:09:40.242885+00:00 app[web.1]: Unhandled rejection
Sequelize error:
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432
2017-05-02T16:09:40.242902+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:98:20
2017-05-02T16:09:40.242903+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/pg/lib/client.js:186:5)
2017-05-02T16:09:40.242904+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-05-02T16:09:40.242905+00:00 app[web.1]: at Connection.emit (events.js:188:7)
2017-05-02T16:09:40.242905+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:86:10)
2017-05-02T16:09:40.242906+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-05-02T16:09:40.242907+00:00 app[web.1]: at emitErrorNT (net.js:1281:8)
2017-05-02T16:09:40.242907+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-05-02T16:09:40.242909+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:104:9)
2017-05-02T16:09:40.242908+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-02T16:09:40.360035+00:00 heroku[web.1]: Process exited with status 0
2017-05-02T16:09:40.373996+00:00 heroku[web.1]: State changed from starting to crashed
This is my index.js:
'use strict';
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(module.filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};
if (config.use_env_variable) {
const sequelize = new Sequelize(process.env[config.use_env_variable]);
} else {
const sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter((file) => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach((file) => {
const model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
Object.keys(db).forEach((modelName) => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
config.json:
{
"development": {
"username": "",
"password": "",
"database": "late_file",
"host": "127.0.0.1",
"dialect": "postgres"
},
"test": {
"username": "",
"password": "",
"database": "database_test",
"host": "127.0.0.1",
"dialect": "postgres"
},
"production": {
"use_env_variable": "DATABASE_URL",
"dialect": "postgres"
}
}
.env, modified to exclude specific names of things
DB_HOST=localhost
DB_USER=
DB_PASS=
DB_NAME=
DB_SSL=true if heroku
DB_PORT=5432
DATABASE_URL=postgres://appropriate/url
applicable part of server.js
const pg = require('pg');
pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL, function(err, client) {
if (err) throw err;
console.log('Connected to postgres! Getting schemas...');
client
.query('SELECT table_schema,table_name FROM information_schema.tables;')
.on('row', function(row) {
console.log(JSON.stringify(row));
});
});
Any help would be greatly appreciated!
Thanks in advance for anyone who offers any support!

Brandon,
I am running an app on Heroku using JAWS_DB and MySQL, but otherwise identical config.json and index.js. In my case on Heroku, the "if (config.use_env_variable) {const sequelize = new Sequelize(process.env[config.use_env_variable])" statement connects to the database without error. The logs appear to point to the "pg.connect" failing in server.js. It's not clear to me (without seeing the rest of your code) why you need to connect to the database in index.js, and then connect again in server.js. If you can remove the connection from pg.connect and try to run with just the connection from index.js it may stop this error.

Related

Heroku Tails suggesting postgres database column doesn't exist, but it does and works in localhost

I have an app deployed on heroku. My production and dev environments both use PostgreSQL and I use knex for my database querying. I am getting an issue where no resources load onto a page and heroku log --tail says this:
2022-08-23T21:34:19.565970+00:00 app[web.1]: There is an error here: select *, "authors"."name" as "author_name", "authors"."id" as "author_id" from "books" inner join "authors" on "books"."author_id" = "authors"."id" where "books"."id" = $1 limit $2 - column books.author_id does not exist
However, the call works fine on localhost - I have checked my database schema on pgadmin and it appears that the column does exist.
Here is the call to the database:
function getBookById(id) {
console.log(id)
return db('books')
.join('authors', 'books.author_id', 'authors.id')
.where('books.id', id)
.select('*', 'authors.name as author_name', 'authors.id as author_id')
.first()
}
I have done a bit more diving in and looks like it is breaking on a number of database hits and returning 503s.
Here is some more error messages I am getting when I run heroku log --tail
2022-08-24T02:25:36.434109+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
2022-08-24T02:25:36.434109+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2022-08-24T02:25:36.434110+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2022-08-24T02:25:36.434110+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
2022-08-24T02:25:36.434111+00:00 app[web.1]: at TLSSocket.emit (node:events:513:28)
2022-08-24T02:25:36.434112+00:00 app[web.1]: at addChunk (node:internal/streams/readable:315:12)
2022-08-24T02:25:36.434112+00:00 app[web.1]: at readableAddChunk (node:internal/streams/readable:289:9)
2022-08-24T02:25:36.434112+00:00 app[web.1]: at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
2022-08-24T02:25:36.434113+00:00 app[web.1]: at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {
2022-08-24T02:25:36.434113+00:00 app[web.1]: length: 127,
2022-08-24T02:25:36.434114+00:00 app[web.1]: severity: 'ERROR',
2022-08-24T02:25:36.434114+00:00 app[web.1]: code: '42703',
2022-08-24T02:25:36.434114+00:00 app[web.1]: detail: undefined,
2022-08-24T02:25:36.434115+00:00 app[web.1]: hint: undefined,
2022-08-24T02:25:36.434115+00:00 app[web.1]: position: '22',
2022-08-24T02:25:36.434115+00:00 app[web.1]: internalPosition: undefined,
2022-08-24T02:25:36.434115+00:00 app[web.1]: internalQuery: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: where: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: schema: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: table: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: column: undefined,
2022-08-24T02:25:36.434117+00:00 app[web.1]: dataType: undefined,
2022-08-24T02:25:36.434117+00:00 app[web.1]: constraint: undefined,
2022-08-24T02:25:36.434117+00:00 app[web.1]: file: 'parse_target.c',
2022-08-24T02:25:36.434118+00:00 app[web.1]: line: '1061',
2022-08-24T02:25:36.434118+00:00 app[web.1]: routine: 'checkInsertTargets'
2022-08-24T02:25:36.434118+00:00 app[web.1]: }
2022-08-24T02:25:36.434240+00:00 app[web.1]: There is an error here: insert into "books" ("author_id", "blurb", "cover_image", "genre", "pub_year", "title") values ($1, $2, $3, $4, $5, $6) returning "id" - column "author_id" of relation "books" does not exist
I'm not sure if this is something weird with heroku's postgres - or something I'm doing wrong (more likely). It is unclear to me how to further trouble shoot this issue.
Thanks for an help

Vapor Server of Heroku Crashes: Possible Postgres Library Issue?

I'm putting this new information first: the problem that brought me to this point is below.
This is what I get once my app deploys to Heroku: seems to compile fine, though there is the issue described in the original section of the post. Now, following the suggestion in the comments, the authentication error seems to be gon, but an encryption problem has arisen...
2022-04-20T07:05:05.960239+00:00 heroku[web.1]: State changed from crashed to starting
2022-04-20T07:05:08.667673+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 57625`
2022-04-20T07:05:10.017468+00:00 app[web.1]: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PostgresNIO.PSQLError(base: PostgresNIO.PSQLError.Base.server(PostgresNIO.PostgresBackendMessage.ErrorResponse(fields: [Line: "545", Severity: "FATAL", Localized Severity: "FATAL", Code: "28000", File: "auth.c", Routine: "ClientAuthentication", Message: "no pg_hba.conf entry for host \"52.87.192.140\", user \"gcnpqdmtllqlsa\", database \"d71dlsuretksud\", no encryption"])))
2022-04-20T07:05:10.017484+00:00 app[web.1]: Current stack trace:
2022-04-20T07:05:10.017998+00:00 app[web.1]: 0 libswiftCore.so 0x00007fb4a3e93210 swift_reportError + 50
2022-04-20T07:05:10.018318+00:00 app[web.1]: 1 libswiftCore.so 0x00007fb4a3f07fc0 _swift_stdlib_reportFatalErrorInFile + 112
2022-04-20T07:05:10.018535+00:00 app[web.1]: 2 libswiftCore.so 0x00007fb4a3bf0c40 _assertionFailure(_:_:file:line:flags:) + 1329
2022-04-20T07:05:10.018759+00:00 app[web.1]: 3 libswiftCore.so 0x00007fb4a3c5fea0 swift_errorInMain + 1075
2022-04-20T07:05:10.018772+00:00 app[web.1]: 4 0x000055b6cab352e8 <unavailable> + 10863336
2022-04-20T07:05:10.018824+00:00 app[web.1]: 5 libc.so.6 0x00007fb4a2ca8fc0 __libc_start_main + 243
2022-04-20T07:05:10.018826+00:00 app[web.1]: 6 0x000055b6ca23aeae <unavailable> + 1449646
2022-04-20T07:05:10.018870+00:00 app[web.1]: Received signal 4. Backtrace:
2022-04-20T07:05:10.231212+00:00 app[web.1]: 0x55b6ca473552, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /tmp/build_64fa1ab2/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
2022-04-20T07:05:10.231216+00:00 app[web.1]: 0x7fb4a3a6d3bf
2022-04-20T07:05:10.231216+00:00 app[web.1]: 0x7fb4a3bf1307
2022-04-20T07:05:10.231216+00:00 app[web.1]: 0x7fb4a3c602d2
2022-04-20T07:05:10.231242+00:00 app[web.1]: 0x55b6cab352e7, main at /tmp/build_64fa1ab2/<compiler-generated>:0
2022-04-20T07:05:10.231250+00:00 app[web.1]: 0x7fb4a2ca90b2
2022-04-20T07:05:10.231258+00:00 app[web.1]: 0x55b6ca23aead
2022-04-20T07:05:10.231260+00:00 app[web.1]: 0xffffffffffffffff
2022-04-20T07:05:10.354561+00:00 heroku[web.1]: Process exited with status 132
2022-04-20T07:05:10.414827+00:00 heroku[web.1]: State changed from starting to crashed
2022-04-20T07:05:10.424640+00:00 heroku[web.1]: State changed from crashed to starting
2022-04-20T07:05:13.246896+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 54624`
2022-04-20T07:05:14.462106+00:00 app[web.1]: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PostgresNIO.PSQLError(base: PostgresNIO.PSQLError.Base.server(PostgresNIO.PostgresBackendMessage.ErrorResponse(fields: [Severity: "FATAL", Code: "28000", File: "auth.c", Localized Severity: "FATAL", Line: "545", Routine: "ClientAuthentication", Message: "no pg_hba.conf entry for host \"3.237.11.112\", user \"gcnpqdmtllqlsa\", database \"d71dlsuretksud\", no encryption"])))
2022-04-20T07:05:14.462121+00:00 app[web.1]: Current stack trace:
2022-04-20T07:05:14.462395+00:00 app[web.1]: 0 libswiftCore.so 0x00007fe7be7d4210 swift_reportError + 50
2022-04-20T07:05:14.462580+00:00 app[web.1]: 1 libswiftCore.so 0x00007fe7be848fc0 _swift_stdlib_reportFatalErrorInFile + 112
2022-04-20T07:05:14.462693+00:00 app[web.1]: 2 libswiftCore.so 0x00007fe7be531c40 _assertionFailure(_:_:file:line:flags:) + 1329
2022-04-20T07:05:14.462816+00:00 app[web.1]: 3 libswiftCore.so 0x00007fe7be5a0ea0 swift_errorInMain + 1075
2022-04-20T07:05:14.462824+00:00 app[web.1]: 4 0x000055ab278fb2e8 <unavailable> + 10863336
2022-04-20T07:05:14.462847+00:00 app[web.1]: 5 libc.so.6 0x00007fe7bd5e9fc0 __libc_start_main + 243
2022-04-20T07:05:14.462849+00:00 app[web.1]: 6 0x000055ab27000eae <unavailable> + 1449646
2022-04-20T07:05:14.462881+00:00 app[web.1]: Received signal 4. Backtrace:
2022-04-20T07:05:14.631921+00:00 app[web.1]: 0x55ab27239552, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /tmp/build_64fa1ab2/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
2022-04-20T07:05:14.631960+00:00 app[web.1]: 0x7fe7be3ae3bf
2022-04-20T07:05:14.631979+00:00 app[web.1]: 0x7fe7be532307
2022-04-20T07:05:14.631996+00:00 app[web.1]: 0x7fe7be5a12d2
2022-04-20T07:05:14.632053+00:00 app[web.1]: 0x55ab278fb2e7, main at /tmp/build_64fa1ab2/<compiler-generated>:0
2022-04-20T07:05:14.632070+00:00 app[web.1]: 0x7fe7bd5ea0b2
2022-04-20T07:05:14.632086+00:00 app[web.1]: 0x55ab27000ead
2022-04-20T07:05:14.632101+00:00 app[web.1]: 0xffffffffffffffff
2022-04-20T07:05:14.757480+00:00 heroku[web.1]: Process exited with status 132
2022-04-20T07:05:14.897128+00:00 heroku[web.1]: State changed from starting to crashed
2022-04-20T07:05:27.957078+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-journey-01336.herokuapp.com request_id=4e9b80e0-0b48-4075-be82-08ed26aa14b8 fwd="49.156.46.15" dyno= connect= service= status=503 bytes= protocol=http
ORIGINAL POST =====================
I have a production server that works fine. I'm implementing a Staging server, and with a few bumps to get it to deploy, it now does that.
However, after launching, it crashes when I try to load it at https: with no certificate. I then restarted, and loaded it as http: but still got this feedback in Heroku logs:
022-04-20T06:15:47.340383+00:00 heroku[web.1]: State changed from crashed to starting
2022-04-20T06:15:50.014593+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 57964`
2022-04-20T06:15:51.051520+00:00 app[web.1]: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PostgresNIO.PSQLError(base: PostgresNIO.PSQLError.Base.connectionError(underlying: NIOSSL.NIOSSLError.handshakeFailed(NIOSSL.BoringSSLError.sslError([Error: 268435581 error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED]))))
2022-04-20T06:15:51.051534+00:00 app[web.1]: Current stack trace:
2022-04-20T06:15:51.051817+00:00 app[web.1]: 0 libswiftCore.so 0x00007f5736109210 swift_reportError + 50
2022-04-20T06:15:51.051993+00:00 app[web.1]: 1 libswiftCore.so 0x00007f573617dfc0 _swift_stdlib_reportFatalErrorInFile + 112
2022-04-20T06:15:51.052106+00:00 app[web.1]: 2 libswiftCore.so 0x00007f5735e66c40 _assertionFailure(_:_:file:line:flags:) + 1329
2022-04-20T06:15:51.052221+00:00 app[web.1]: 3 libswiftCore.so 0x00007f5735ed5ea0 swift_errorInMain + 1075
2022-04-20T06:15:51.052229+00:00 app[web.1]: 4 0x000055c7c48aa528 <unavailable> + 10863912
2022-04-20T06:15:51.052252+00:00 app[web.1]: 5 libc.so.6 0x00007f5734f1efc0 __libc_start_main + 243
2022-04-20T06:15:51.052254+00:00 app[web.1]: 6 0x000055c7c3fafeae <unavailable> + 1449646
2022-04-20T06:15:51.052284+00:00 app[web.1]: Received signal 4. Backtrace:
2022-04-20T06:15:51.189690+00:00 app[web.1]: 0x55c7c41e8792, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /tmp/build_113febab/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
2022-04-20T06:15:51.189696+00:00 app[web.1]: 0x7f5735ce33bf
2022-04-20T06:15:51.189696+00:00 app[web.1]: 0x7f5735e67307
2022-04-20T06:15:51.189697+00:00 app[web.1]: 0x7f5735ed62d2
2022-04-20T06:15:51.189697+00:00 app[web.1]: 0x55c7c48aa527, main at /tmp/build_113febab/<compiler-generated>:0
2022-04-20T06:15:51.189698+00:00 app[web.1]: 0x7f5734f1f0b2
2022-04-20T06:15:51.189698+00:00 app[web.1]: 0x55c7c3fafead
2022-04-20T06:15:51.189698+00:00 app[web.1]: 0xffffffffffffffff
2022-04-20T06:15:51.318955+00:00 heroku[web.1]: Process exited with status 132
2022-04-20T06:15:51.366529+00:00 heroku[web.1]: State changed from starting to crashed
2022-04-20T06:15:54.612759+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-journey-01336.herokuapp.com request_id=de9eeae6-ed50-46a7-8008-9e4c4937d71f fwd="49.156.46.15" dyno= connect= service= status=503 bytes= protocol=http
The PostgresNIO.PSQLError may relate to a problem that showed up while uploading it, where the compiler complained that a method being used in one of the Postgres libraries:
[898/900] Compiling PostgresKit ConnectionPool+Postgres.swift
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:53:39: warning: 'connect(to:tlsConfiguration:serverHostname:logger:on:)' is deprecated: Use the new connect method that allows you to connect and authenticate in a single step
return PostgresConnection.connect(
^
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:53:39: note: use 'connect(on:configuration:id:logger:)' instead
return PostgresConnection.connect(
^~~~~~~
connect
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:60:29: warning: 'authenticate(username:database:password:logger:)' is deprecated: Use the new connect method that allows you to connect and authenticate in a single step
return conn.authenticate(
^
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:60:29: note: use 'connect(on:configuration:id:logger:)' instead
return conn.authenticate(
^~~~~~~~~~~~
connect
[899/901] Compiling FluentPostgresDriver Exports.swift
Can anyone provide any context here, or a solution? My intention was to run the Staging server without SSL for now, but I wonder if that would help anyway, if the above is the problem, since it comes up during compile... no other errors are reported during the push to Heroku, btw.
It is about correct database connection configuration
In our case on heroku we set database url
postgres://xxx:yyy#zzz.compute-1.amazonaws.com:5432/asdfasgsgbwev
And tlsConfig.certificateVerification = .none

How to use the Heroku DATABASE_URL environment variable in Scala?

I am trying to deploy my app to Heroku. Heroku provides a DATABASE_URL environment variable. I am wondering what is the best way to use this.
When in dev the DATABASE_URL environment variable will be jdbc:postgresql://localhost:5400/bookswapdb
When in prd the DATABASE_URL environment variable will be something like this: postgres://<USER>:<PASSWORD>#<HOST>:<PORT>/<DATABASE>
Is checking the DATABASE_URL really the best way to discover whether the app is in prod or dev? (I would have thought they would also pass in a variable like ENV=prd or PRD=true)
Given the code below, what is the smartest way to achieve checking the DATABASE_URL and passing it into initFlyway function.
What's the cleanest way to chop up this string to get the details i need postgres://<USER>:<PASSWORD>#<HOST>:<PORT>/<DATABASE>
The DATABASE_URL might be in this format: jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password> if so how is the best way to divide that?
The below doesn't seem to work when deployed to heroku but it does work on a local db.
package com.fullstackryan.appone.server
import cats.effect.{ConcurrentEffect, ContextShift, Sync, Timer}
import cats.implicits._
import com.fullstackryan.appone.config.{Config, DbConfig, LoadConfig, ServerConfig}
import com.fullstackryan.appone.database.Database
import com.fullstackryan.appone.repo.{BookSwap, HelloWorld, Jokes}
import com.fullstackryan.appone.routing.ApponeRoutes
import fs2.Stream
import org.flywaydb.core.Flyway
import org.http4s.client.blaze.BlazeClientBuilder
import org.http4s.implicits._
import org.http4s.server.blaze.BlazeServerBuilder
import org.http4s.server.middleware.Logger
import pureconfig.generic.auto._
import java.net.URI
import scala.concurrent.ExecutionContext.global
object ApponeServer {
def initFlyway[F[_] : Sync](url: String, username: String, password: String): F[Int] = Sync[F].delay {
val flyway = Flyway.configure().dataSource(url, username, password).baselineOnMigrate(true).load()
println("inside flyway")
flyway.migrate()
}
def prodConfig(): Config = {
val dbUri = new URI(System.getenv("DATABASE_URL"))
val username = dbUri.getUserInfo.split(":")(0)
val password = dbUri.getUserInfo.split(":")(1)
val dbUrl = "jdbc:postgresql://" + dbUri.getHost + dbUri.getPath
Config(ServerConfig(5432, dbUri.getHost), DbConfig(dbUrl, username, password, 10))
}
def stream[F[_] : ConcurrentEffect : ContextShift : Timer]: Stream[F, Nothing] = {
for {
client <- BlazeClientBuilder[F](global).stream
// below line loads config from application.conf
config <- Stream.eval(LoadConfig[F, Config].load)
// This is meant to check if DATABASE_URL is dev or prd
isProdConfig = if (config.dbConfig.url.contains("localhost")) config else prodConfig()
// Below line hopefully passes correct prd or dev config into initFlyway to get a connnection
_ <- Stream.eval(initFlyway(isProdConfig.dbConfig.url, isProdConfig.dbConfig.username, isProdConfig.dbConfig.password))
xa <- Stream.resource(Database.transactor(isProdConfig.dbConfig))
helloWorldAlg = HelloWorld.impl[F]
jokeAlg = Jokes.impl[F](client)
bookAlg = BookSwap.buildInstance[F](xa)
httpApp = (
ApponeRoutes.helloWorldRoutes[F](helloWorldAlg) <+>
ApponeRoutes.bookRoutes[F](bookAlg) <+>
ApponeRoutes.jokeRoutes[F](jokeAlg)
).orNotFound
finalHttpApp = Logger.httpApp(true, true)(httpApp)
exitCode <- BlazeServerBuilder[F](global)
.bindHttp(8080, "0.0.0.0")
.withHttpApp(finalHttpApp)
.serve
} yield exitCode
}.drain
}
ERROR
2021-01-17T14:05:29.437876+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-17T14:05:35.808791+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/appone -Dhttp.port=${PORT}`
2021-01-17T14:05:39.711887+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-01-17T14:05:40.047036+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-01-17T14:05:48.838694+00:00 app[web.1]: [ioapp-compute-0] INFO o.h.c.PoolManager - Shutting down connection pool: curAllocated=0 idleQueues.size=0 waitQueue.size=0 maxWaitQueueLimit=256 closed=false
2021-01-17T14:05:48.972995+00:00 app[web.1]: pureconfig.error.ConfigReaderException: Cannot convert configuration to a scala.runtime.Nothing$. Failures are:
2021-01-17T14:05:48.973019+00:00 app[web.1]: at 'appone.db-config':
2021-01-17T14:05:48.973021+00:00 app[web.1]: - (application.conf # jar:file:/app/target/universal/stage/lib/com.fullstackryan.appone-0.0.1-SNAPSHOT.jar!/application.conf: 10) Key not found: 'username'.
2021-01-17T14:05:48.973022+00:00 app[web.1]: - (application.conf # jar:file:/app/target/universal/stage/lib/com.fullstackryan.appone-0.0.1-SNAPSHOT.jar!/application.conf: 10) Key not found: 'password'.
2021-01-17T14:05:48.977706+00:00 app[web.1]:
2021-01-17T14:05:48.977988+00:00 app[web.1]: at com.fullstackryan.appone.config.LoadConfig$$anon$1.$anonfun$load$1(LoadConfig.scala:25)
2021-01-17T14:05:48.978182+00:00 app[web.1]: at cats.syntax.EitherOps$.leftMap$extension(either.scala:172)
2021-01-17T14:05:48.992062+00:00 app[web.1]: at com.fullstackryan.appone.config.LoadConfig$$anon$1.load(LoadConfig.scala:25)
2021-01-17T14:05:48.992224+00:00 app[web.1]: at com.fullstackryan.appone.server.ApponeServer$.$anonfun$stream$1(ApponeServer.scala:50)
2021-01-17T14:05:48.992352+00:00 app[web.1]: at com.fullstackryan.appone.server.ApponeServer$.$anonfun$stream$1$adapted(ApponeServer.scala:48)
2021-01-17T14:05:48.992496+00:00 app[web.1]: at fs2.Stream$.$anonfun$flatMap$1(Stream.scala:1188)
2021-01-17T14:05:48.992649+00:00 app[web.1]: at fs2.internal.FreeC$.go$2(Algebra.scala:609)
2021-01-17T14:05:48.992861+00:00 app[web.1]: at fs2.internal.FreeC$.$anonfun$flatMapOutput$1(Algebra.scala:616)
2021-01-17T14:05:48.993129+00:00 app[web.1]: at fs2.internal.FreeC$$anon$1.cont(Algebra.scala:53)
2021-01-17T14:05:48.996922+00:00 app[web.1]: at fs2.internal.FreeC$ViewL$$anon$9$$anon$10.cont(Algebra.scala:242)
2021-01-17T14:05:48.997120+00:00 app[web.1]: at fs2.internal.FreeC$ViewL$.mk(Algebra.scala:231)
2021-01-17T14:05:48.997247+00:00 app[web.1]: at fs2.internal.FreeC$ViewL$.apply(Algebra.scala:220)
2021-01-17T14:05:48.997395+00:00 app[web.1]: at fs2.internal.FreeC.viewL(Algebra.scala:106)
2021-01-17T14:05:48.997537+00:00 app[web.1]: at fs2.internal.FreeC$.go$1(Algebra.scala:414)
2021-01-17T14:05:48.997707+00:00 app[web.1]: at fs2.internal.FreeC$.$anonfun$compile$8(Algebra.scala:464)
2021-01-17T14:05:48.998481+00:00 app[web.1]: at fs2.internal.FreeC$.$anonfun$compile$1(Algebra.scala:430)
2021-01-17T14:05:48.998648+00:00 app[web.1]: at map # fs2.internal.CompileScope.interruptibleEval(CompileScope.scala:393)
2021-01-17T14:05:48.998778+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.go$1(Algebra.scala:490)
2021-01-17T14:05:48.998907+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.$anonfun$compile$5(Algebra.scala:450)
2021-01-17T14:05:48.999061+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.go$1(Algebra.scala:447)
2021-01-17T14:05:48.999202+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:05:48.999348+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:05:49.000021+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.$anonfun$acquireResource$4(CompileScope.scala:185)
2021-01-17T14:05:49.000182+00:00 app[web.1]: at flatten # fs2.internal.ScopedResource$$anon$1.acquired(ScopedResource.scala:139)
2021-01-17T14:05:49.000285+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.$anonfun$acquireResource$1(CompileScope.scala:183)
2021-01-17T14:05:49.000409+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.acquireResource(CompileScope.scala:180)
2021-01-17T14:05:49.000547+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.$anonfun$compile$10(Algebra.scala:498)
2021-01-17T14:05:49.000665+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:05:49.000782+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:05:49.000911+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:05:49.001062+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.$anonfun$acquireResource$4(CompileScope.scala:185)
2021-01-17T14:05:49.001165+00:00 app[web.1]: at flatten # fs2.internal.ScopedResource$$anon$1.acquired(ScopedResource.scala:139)
2021-01-17T14:05:49.171354+00:00 heroku[web.1]: Process exited with status 1
2021-01-17T14:05:49.208726+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-17T14:05:49.211138+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-17T14:05:55.214070+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/appone -Dhttp.port=${PORT}`
2021-01-17T14:05:58.596071+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-01-17T14:05:58.994577+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-01-17T14:05:59.000000+00:00 app[api]: Build succeeded
2021-01-17T14:06:04.235862+00:00 app[web.1]: [ioapp-compute-0] INFO o.h.c.PoolManager - Shutting down connection pool: curAllocated=0 idleQueues.size=0 waitQueue.size=0 maxWaitQueueLimit=256 closed=false
2021-01-17T14:06:04.319171+00:00 app[web.1]: pureconfig.error.ConfigReaderException: Cannot convert configuration to a scala.runtime.Nothing$. Failures are:
2021-01-17T14:06:04.319174+00:00 app[web.1]: at 'appone.db-config':
2021-01-17T14:06:04.319195+00:00 app[web.1]: - (application.conf # jar:file:/app/target/universal/stage/lib/com.fullstackryan.appone-0.0.1-SNAPSHOT.jar!/application.conf: 10) Key not found: 'username'.
2021-01-17T14:06:04.319196+00:00 app[web.1]: - (application.conf # jar:file:/app/target/universal/stage/lib/com.fullstackryan.appone-0.0.1-SNAPSHOT.jar!/application.conf: 10) Key not found: 'password'.
2021-01-17T14:06:04.319206+00:00 app[web.1]:
2021-01-17T14:06:04.319341+00:00 app[web.1]: at com.fullstackryan.appone.config.LoadConfig$$anon$1.$anonfun$load$1(LoadConfig.scala:25)
2021-01-17T14:06:04.319403+00:00 app[web.1]: at cats.syntax.EitherOps$.leftMap$extension(either.scala:172)
2021-01-17T14:06:04.319496+00:00 app[web.1]: at com.fullstackryan.appone.config.LoadConfig$$anon$1.load(LoadConfig.scala:25)
2021-01-17T14:06:04.319683+00:00 app[web.1]: at com.fullstackryan.appone.server.ApponeServer$.$anonfun$stream$1(ApponeServer.scala:50)
2021-01-17T14:06:04.319688+00:00 app[web.1]: at com.fullstackryan.appone.server.ApponeServer$.$anonfun$stream$1$adapted(ApponeServer.scala:48)
2021-01-17T14:06:04.319785+00:00 app[web.1]: at fs2.Stream$.$anonfun$flatMap$1(Stream.scala:1188)
2021-01-17T14:06:04.319847+00:00 app[web.1]: at fs2.internal.FreeC$.go$2(Algebra.scala:609)
2021-01-17T14:06:04.319951+00:00 app[web.1]: at fs2.internal.FreeC$.$anonfun$flatMapOutput$1(Algebra.scala:616)
2021-01-17T14:06:04.320042+00:00 app[web.1]: at fs2.internal.FreeC$$anon$1.cont(Algebra.scala:53)
2021-01-17T14:06:04.320188+00:00 app[web.1]: at fs2.internal.FreeC$ViewL$$anon$9$$anon$10.cont(Algebra.scala:242)
2021-01-17T14:06:04.320257+00:00 app[web.1]: at fs2.internal.FreeC$ViewL$.mk(Algebra.scala:231)
2021-01-17T14:06:04.320336+00:00 app[web.1]: at fs2.internal.FreeC$ViewL$.apply(Algebra.scala:220)
2021-01-17T14:06:04.320405+00:00 app[web.1]: at fs2.internal.FreeC.viewL(Algebra.scala:106)
2021-01-17T14:06:04.320481+00:00 app[web.1]: at fs2.internal.FreeC$.go$1(Algebra.scala:414)
2021-01-17T14:06:04.320561+00:00 app[web.1]: at fs2.internal.FreeC$.$anonfun$compile$8(Algebra.scala:464)
2021-01-17T14:06:04.320641+00:00 app[web.1]: at fs2.internal.FreeC$.$anonfun$compile$1(Algebra.scala:430)
2021-01-17T14:06:04.320719+00:00 app[web.1]: at map # fs2.internal.CompileScope.interruptibleEval(CompileScope.scala:393)
2021-01-17T14:06:04.320785+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.go$1(Algebra.scala:490)
2021-01-17T14:06:04.320862+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.$anonfun$compile$5(Algebra.scala:450)
2021-01-17T14:06:04.320929+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.go$1(Algebra.scala:447)
2021-01-17T14:06:04.320995+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:06:04.321076+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:06:04.321138+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.$anonfun$acquireResource$4(CompileScope.scala:185)
2021-01-17T14:06:04.321230+00:00 app[web.1]: at flatten # fs2.internal.ScopedResource$$anon$1.acquired(ScopedResource.scala:139)
2021-01-17T14:06:04.321289+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.$anonfun$acquireResource$1(CompileScope.scala:183)
2021-01-17T14:06:04.321385+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.acquireResource(CompileScope.scala:180)
2021-01-17T14:06:04.321473+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.$anonfun$compile$10(Algebra.scala:498)
2021-01-17T14:06:04.321531+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:06:04.321607+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:06:04.321668+00:00 app[web.1]: at flatMap # fs2.internal.FreeC$.interruptGuard$1(Algebra.scala:429)
2021-01-17T14:06:04.321779+00:00 app[web.1]: at flatMap # fs2.internal.CompileScope.$anonfun$acquireResource$4(CompileScope.scala:185)
2021-01-17T14:06:04.321811+00:00 app[web.1]: at flatten # fs2.internal.ScopedResource$$anon$1.acquired(ScopedResource.scala:139)
2021-01-17T14:06:04.453054+00:00 heroku[web.1]: Process exited with status 1
2021-01-17T14:06:04.497636+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-17T14:28:36.868097+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=appone2021.herokuapp.com request_id=a2e9c2cb-9e29-4e90-a528-2b93822a5b22 fwd="2.221.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-17T14:28:37.225963+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=appone2021.herokuapp.com request_id=d1e00110-d2b1-4512-9391-2ab54ac11947 fwd="2.221.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-17T14:42:04.309046+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=appone2021.herokuapp.com request_id=b6446286-f99c-4490-9ed4-ed8071f2d5c1 fwd="2.221.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-17T14:42:04.481028+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=appone2021.herokuapp.com request_id=c6bff236-696b-491d-9831-930f1d114fd8 fwd="2.221.116.154" dyno= connect= service= status=503 bytes= protocol=https
2021-01-17T14:45:18.000000+00:00 app[api]: Build started by user fullstackryan#gmail.com
2021-01-17T14:46:57.165052+00:00 app[api]: Release v25 created by user fullstackryan#gmail.com
2021-01-17T14:46:57.165052+00:00 app[api]: Deploy 5ab4cf89 by user fullstackryan#gmail.com
2021-01-17T14:46:58.334991+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-17T14:47:02.441681+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/appone -Dhttp.port=${PORT}`
2021-01-17T14:47:04.351208+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-01-17T14:47:04.458310+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
You seem to have most of the pieces, but I don't think you're putting them together correctly.
Heroku Postgres sets the DATABASE_URL environment variable for you:
As part of the provisioning process, a DATABASE_URL config var is added to your app’s configuration. This contains the URL your app uses to access the database.
You appear to already be using this environment variable in your application.conf:
db-config {
driver = "org.postgresql.Driver"
url = ${?DATABASE_URL}
username = ${?DATABASE_USERNAME}
password = ${?DATABASE_PASSWORD}
connection-threads = 4
pool-size = 10
}
The problem is that you are also depending on environment variables called DATABASE_USERNAME and DATABASE_PASSWORD, which Heroku does not provide. That's what is causing your application to fail:
pureconfig.error.ConfigReaderException: Cannot convert configuration to a scala.runtime.Nothing$. Failures are:
at 'appone.db-config':
- (application.conf # jar:file:/app/target/universal/stage/lib/com.fullstackryan.appone-0.0.1-SNAPSHOT.jar!/application.conf: 10) Key not found: 'username'.
- (application.conf # jar:file:/app/target/universal/stage/lib/com.fullstackryan.appone-0.0.1-SNAPSHOT.jar!/application.conf: 10) Key not found: 'password'.
You could try setting them with heroku config:set, but that's not a good idea because
The value of your app’s DATABASE_URL config var might change at any time. You should not rely on this value either inside or outside your Heroku app.
I suggest only setting the url in your application.conf. Then, in your application code, you can parse the URL and connect to your database as you are already trying to do. Since it is a URL, your current approach of instantiating a URI is a good fit.
Side note: Your application code is currently getting DATABASE_URL directly from the environment again. I suspect it would be more idiomatic to retrieve it from whatever configuration object you get from your application.conf, where you have set db-config.url. But I'm not experienced enough in Scala to show the correct approach.
The line below
config <- Stream.eval(LoadConfig[F, Config].load)
was reading my application.conf file which in dev mode is fine as I source the variables mentioned within the application.conf by running source meta/dev.env. meta/dev.env being the location where I store the environment variables mentioned in the application.conf.
However in production (specifically Heroku environment) I could not source meta/prd.env because I could not store variables statically in that location/file as Heroku updates its variables every so often, meaning those variables would become out of date.
With the above in mind, I had to code in such as way that every time the application is run, my apps gets the DATABASE_URL variable injected by Heroku. I created a function for this:
def prodConfig(): Config = {
val dbUri = new URI(System.getenv("DATABASE_URL"))
val username = dbUri.getUserInfo.split(":")(0)
val password = dbUri.getUserInfo.split(":")(1)
val dbUrl = "jdbc:postgresql://" + dbUri.getHost + dbUri.getPath
Config(ServerConfig(5432, dbUri.getHost), DbConfig(dbUrl, username, password, 10))
}
The above code gets DATABASE_URL by using System.getenv("DATABASE_URL"). Then the function splits it into various parts such as username, password etc which I can then pass database config etc.
When in dev I uncomment the first line below and comment out the second line below.
// config <- Stream.eval(LoadConfig[F, Config].load)
conifg = prodConfig()
In dev it reads from application.conf and in prod it will do the System.getenv("DATABASE_URL") which rely on heroku to make sure its provided.
It's not the nicest solution as it relies on commenting and uncommenting when in dev mode but for now it's the best I've got. Would love to hear recommendations on how to make this better.
Hope this helps others who are stuck.
I recommend using JDBC_DATABASE_URL instead. It will be automatically set for your app: https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#using-the-database_url-in-plain-jdbc

Heroku app fails to connect to mongodb atlas server (after migration from mlab)

I recently migrated from mlab to mongodb atlas due to its deprecation. I managed to successfully get a connection to the db and tested it with the mongoDB compass but when I add the environment variable to heroku it gives me the following error message:
MongoNetworkError: failed to connect to server [cluster-grwbxfbx-shard-00-02.e6jtl.mongodb.net:27017] on first connect [MongoNetworkError: connection 4 to cluster-grwbxfbx-shard-00-02.e6jtl.mongodb.net:27017 closed
2020-11-11T23:53:44.726144+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connection.js:372:9)
2020-11-11T23:53:44.726144+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2020-11-11T23:53:44.726145+00:00 app[web.1]: at TLSSocket.emit (events.js:314:20)
2020-11-11T23:53:44.726145+00:00 app[web.1]: at net.js:676:12
2020-11-11T23:53:44.726146+00:00 app[web.1]: at TCP.done (_tls_wrap.js:568:7)]
2020-11-11T23:53:44.726147+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb/lib/core/topologies/server.js:438:11)
2020-11-11T23:53:44.726147+00:00 app[web.1]: at Pool.emit (events.js:314:20)
2020-11-11T23:53:44.726148+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/pool.js:562:14
2020-11-11T23:53:44.726149+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/pool.js:1009:9
2020-11-11T23:53:44.726149+00:00 app[web.1]: at callback (/app/node_modules/mongodb/lib/core/connection/connect.js:97:5)
2020-11-11T23:53:44.726150+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/connect.js:124:7
2020-11-11T23:53:44.726150+00:00 app[web.1]: at _callback (/app/node_modules/mongodb/lib/core/connection/connect.js:349:5)
2020-11-11T23:53:44.726151+00:00 app[web.1]: at Connection.errorHandler (/app/node_modules/mongodb/lib/core/connection/connect.js:365:5)
2020-11-11T23:53:44.726151+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2020-11-11T23:53:44.726151+00:00 app[web.1]: at Connection.emit (events.js:314:20)
2020-11-11T23:53:44.726152+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connection.js:370:12)
2020-11-11T23:53:44.726152+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2020-11-11T23:53:44.726153+00:00 app[web.1]: at TLSSocket.emit (events.js:314:20)
2020-11-11T23:53:44.726153+00:00 app[web.1]: at net.js:676:12
2020-11-11T23:53:44.726153+00:00 app[web.1]: at TCP.done (_tls_wrap.js:568:7)
2020-11-11T23:53:44.812696+00:00 heroku[web.1]: Process exited with status 0
2020-11-11T23:53:44.850554+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-11T23:53:44.854049+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-11T23:53:47.149749+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-11T23:53:49.907225+00:00 app[web.1]:
It seems as if heroku is adding a port to the end of the MONGODB_URI. Does anyone know whats going on?
my config var in heroku is:
MONGODB_URI = mongodb+srv://username:password#cluster-grwbxfbx.e6jtl.mongodb.net/test?retryWrites=true&w=majority
with username and password being replaced by my admin username and password.
Also here is my code for connecting to the db
import mongoose from 'mongoose'
import options from '../config'
export const connect = (url = options.dbUrl, opts = {}) => {
return mongoose.connect(url, { ...opts, useNewUrlParser: true })
}
export const config = {
secrets: {
jwt: 'learneverything'
},
dbUrl: process.env.MONGODB_URI || 'mongodb://localhost:27017/api-design'
}
Let me know if you need me to post anything else

error for push on heroku: PG::UndefinedObject: ERROR: type "string" does not exist

I'm trying to push an application for Heroku and I have some errors and don't know what to do. The development mode(webrick server) works fine, send the email, etc...
I'm using a activerecord-tableless for send email contact.
this is my ContactsController:
class ContactsController < ApplicationController
def new
#contact = Contact.new
end
def create
#contact = Contact.new(secure_params)
if #contact.valid?
UserMailer.contact_email(#contact).deliver_now
flash[:notice] = "Message sent from #{#contact.name}."
redirect_to root_path
else
flash.now[:error] = 'Cannot send message.'
render :new
end
end
private
def secure_params
params.require(:contact).permit(:name, :email, :content)
end
end
my Contact class:
class Contact < ActiveRecord::Base
has_no_table
column :name, :string
column :email, :string
column :content, :string
validates_presence_of :name, :email, :content
validates_format_of :email, :with => /\A[-a-z0-9_+\.]+\#([-a-z0-9]+\.)+[a-z0-9]{2,4}\z/i
validates_length_of :content, :maximum => 500
def self.column(name, sql_type = nil, default = nil, null = true)
type = "ActiveRecord::Type::#{sql_type.to_s.camelize}".constantize.new
tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, type, null)
end
end
view new.html.erb:
<% content_for :title do %>Contact<% end %>
<div class="distance">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div align="center">
<h2>Send a message to Us</h2>
<%= simple_form_for #contact do |form| %>
<%= form.error_notification %>
<%= form.input :name, autofocus: true, placeholder: 'Enter name' %>
<%= form.input :email, placeholder: 'Enter email' %>
<%= form.input :content, as: :text, placeholder: 'Enter the content' %>
<%= form.button :submit, 'Submit', class: 'btn btn-info btn-lg' %>
<% end %>
</div>
</div>
</div>
Gemfile:
source 'https://rubygems.org'
ruby '2.2.2'
gem 'rails', '4.2.4'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
gem 'bootstrap-sass'
gem 'figaro', '>= 1.0.0.rc1'
gem 'simple_form'
gem 'font-awesome-sass', '~> 4.4.0'
gem "activerecord-tableless", ">= 1.3.4", git:'https://github.com/david135/activerecord-tableless.git'
group :development do
gem 'better_errors'
gem 'hub', :require=>nil
gem 'quiet_assets'
gem 'rails_layout'
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
gem 'thin'
end
database.yml:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: Rails.application.secrets.domain_name,
authentication: "plain",
enable_starttls_auto: true,
user_name: Rails.application.secrets.email_provider_username,
password: Rails.application.secrets.email_provider_password
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => Rails.application.secrets.domain_name }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["DOMAIN_NAME"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
I'm using the gem figaro and my application.yml is:
GMAIL_USERNAME: 'XXXXXXX'
GMAIL_PASSWORD: 'XXXXXXX'
DOMAIN_NAME: 'XXXXXXX'
OWNER_EMAIL: 'XXXXXXX#mail.com'
When I try to push for heroku I have this error:
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/motaprojectlive.git'
And when I try to run:
$ heroku run rails console
Running `rails console` attached to terminal... up, run.5541
PG::UndefinedObject: ERROR: type "string" does not exist
LINE 1: SELECT 'string'::regtype::oid
^
: SELECT 'string'::regtype::oid
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec': PG::UndefinedObject: ERROR: type "string" does not exist (ActiveRecord::StatementInvalid)
LINE 1: SELECT 'string'::regtype::oid
^
: SELECT 'string'::regtype::oid
from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
$ heroku logs -t
2015-09-15T05:32:26.718951+00:00 app[web.1]: => Booting Thin
2015-09-15T05:32:26.718975+00:00 app[web.1]: => Rails 4.2.4 application starting in production on http://0.0.0.0:47284
2015-09-15T05:32:26.718977+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-09-15T05:32:26.718978+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-09-15T05:32:26.718979+00:00 app[web.1]: PG::UndefinedObject: ERROR: type "string" does not exist
2015-09-15T05:32:26.718981+00:00 app[web.1]: LINE 1: SELECT 'string'::regtype::oid
2015-09-15T05:32:26.718982+00:00 app[web.1]: ^
2015-09-15T05:32:26.718983+00:00 app[web.1]: : SELECT 'string'::regtype::oid
2015-09-15T05:32:26.719031+00:00 app[web.1]: Exiting
2015-09-15T05:32:26.719097+00:00 app[web.1]: /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec': PG::UndefinedObject: ERROR: type "string" does not exist (ActiveRecord::StatementInvalid)
2015-09-15T05:32:26.719099+00:00 app[web.1]: LINE 1: SELECT 'string'::regtype::oid
2015-09-15T05:32:26.719100+00:00 app[web.1]: ^
2015-09-15T05:32:26.719110+00:00 app[web.1]: : SELECT 'string'::regtype::oid
2015-09-15T05:32:26.719114+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract_adapter.rb:473:in `block in log'
2015-09-15T05:32:26.719113+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `block in execute'
2015-09-15T05:32:26.719117+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/abstract_adapter.rb:467:in `log'
2015-09-15T05:32:26.719115+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
2015-09-15T05:32:26.719120+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:154:in `execute'
2015-09-15T05:32:26.719121+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/postgresql_adapter.rb:393:in `lookup_cast_type'
2015-09-15T05:32:26.719122+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/bundler/gems/activerecord-tableless-800393c52bd2/lib/activerecord-tableless.rb:93:in `column'
2015-09-15T05:32:26.719125+00:00 app[web.1]: from /app/app/models/contact.rb:3:in `<class:Contact>'
2015-09-15T05:32:26.719126+00:00 app[web.1]: from /app/app/models/contact.rb:1:in `<top (required)>'
2015-09-15T05:32:26.719132+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
2015-09-15T05:32:26.719129+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
2015-09-15T05:32:26.719142+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:317:in `depend_on'
2015-09-15T05:32:26.719139+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:360:in `require_or_load'
2015-09-15T05:32:26.719135+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
2015-09-15T05:32:26.719147+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
2015-09-15T05:32:26.719136+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
2015-09-15T05:32:26.719187+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:471:in `block in eager_load!'
2015-09-15T05:32:26.719145+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:233:in `require_dependency'
2015-09-15T05:32:26.719191+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:469:in `each'
2015-09-15T05:32:26.719192+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:469:in `eager_load!'
2015-09-15T05:32:26.719150+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:471:in `each'
2015-09-15T05:32:26.719193+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/engine.rb:346:in `eager_load!'
2015-09-15T05:32:26.719196+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
2015-09-15T05:32:26.719197+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `instance_exec'
2015-09-15T05:32:26.719195+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/application/finisher.rb:56:in `each'
2015-09-15T05:32:26.719198+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:30:in `run'
2015-09-15T05:32:26.719199+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:55:in `block in run_initializers'
2015-09-15T05:32:26.719200+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
2015-09-15T05:32:26.719202+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
2015-09-15T05:32:26.719201+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
2015-09-15T05:32:26.719204+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
2015-09-15T05:32:26.719205+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each'
2015-09-15T05:32:26.719207+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
2015-09-15T05:32:26.719206+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `call'
2015-09-15T05:32:26.719210+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
2015-09-15T05:32:26.719211+00:00 app[web.1]: from /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
2015-09-15T05:32:26.719212+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/initializable.rb:54:in `run_initializers'
2015-09-15T05:32:26.719213+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/application.rb:352:in `initialize!'
2015-09-15T05:32:26.719215+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
2015-09-15T05:32:26.719214+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2015-09-15T05:32:26.719216+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `block in require'
2015-09-15T05:32:26.719221+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:274:in `require'
2015-09-15T05:32:26.719222+00:00 app[web.1]: from /app/config.ru:3:in `block in <main>'
2015-09-15T05:32:26.719223+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
2015-09-15T05:32:26.719224+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
2015-09-15T05:32:26.719218+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
2015-09-15T05:32:26.719227+00:00 app[web.1]: from /app/config.ru:in `new'
2015-09-15T05:32:26.719228+00:00 app[web.1]: from /app/config.ru:in `<main>'
2015-09-15T05:32:26.719229+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
2015-09-15T05:32:26.719236+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
2015-09-15T05:32:26.719232+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
2015-09-15T05:32:26.719239+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
2015-09-15T05:32:26.719233+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
2015-09-15T05:32:26.719242+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/server.rb:61:in `app'
2015-09-15T05:32:26.719246+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:272:in `start'
2015-09-15T05:32:26.719243+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
2015-09-15T05:32:26.719248+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start'
2015-09-15T05:32:26.719251+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
2015-09-15T05:32:26.719255+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
2015-09-15T05:32:26.719254+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
2015-09-15T05:32:26.719258+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
2015-09-15T05:32:26.719263+00:00 app[web.1]: from bin/rails:8:in `require'
2015-09-15T05:32:26.719261+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
2015-09-15T05:32:26.719266+00:00 app[web.1]: from bin/rails:8:in `<main>'
2015-09-15T05:32:27.834264+00:00 heroku[web.1]: Process exited with status 1
2015-09-15T05:32:27.853661+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-15T08:20:07.379945+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=motaprojectlive.herokuapp.com request_id=c8265c44-6398-44f4-ae08-a2077171ac55 fwd="46.27.166.60" dyno= connect= service= status=503 bytes=
2015-09-15T08:23:47.348699+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=motaprojectlive.herokuapp.com request_id=576b4f28-174f-4b1e-8700-5053fbf3323c fwd="46.27.166.60" dyno= connect= service= status=503 bytes=
2015-09-15T09:36:03.654458+00:00 heroku[api]: Starting process with command `rails console` by romenigld#gmail.com
2015-09-15T09:36:15.126378+00:00 heroku[run.3618]: Awaiting client
2015-09-15T09:36:15.162910+00:00 heroku[run.3618]: Starting process with command `rails console`
2015-09-15T09:36:15.516485+00:00 heroku[run.3618]: State changed from starting to up
2015-09-15T09:36:20.194081+00:00 heroku[run.3618]: State changed from up to complete
2015-09-15T09:36:20.183530+00:00 heroku[run.3618]: Process exited with status 1
2015-09-15T09:50:59.737668+00:00 heroku[api]: Starting process with command `rails console` by romenigld#gmail.com
2015-09-15T09:51:15.542149+00:00 heroku[run.1439]: Awaiting client
2015-09-15T09:51:15.750707+00:00 heroku[run.1439]: State changed from starting to up
2015-09-15T09:51:15.854508+00:00 heroku[run.1439]: Starting process with command `rails console`
2015-09-15T09:51:21.470332+00:00 heroku[run.1439]: State changed from up to complete
2015-09-15T09:51:21.462321+00:00 heroku[run.1439]: Process exited with status 1
2015-09-15T09:52:05.112988+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-15T09:52:05.113010+00:00 heroku[slug-compiler]: Slug compilation error: slug archive could not be created
2015-09-15T10:15:15.727423+00:00 heroku[api]: Starting process with command `rails console` by romenigld#gmail.com
2015-09-15T10:15:26.853219+00:00 heroku[run.5541]: Awaiting client
2015-09-15T10:15:26.885072+00:00 heroku[run.5541]: Starting process with command `rails console`
2015-09-15T10:15:27.062819+00:00 heroku[run.5541]: State changed from starting to up
2015-09-15T10:15:31.889775+00:00 heroku[run.5541]: State changed from up to complete
2015-09-15T10:15:31.877044+00:00 heroku[run.5541]: Process exited with status 1
Your model is wrong.
These lines shouldn't be there.
column :name, :string
column :email, :string
column :content, :string
Just remove them, it should work.