question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use db:create with postgres

See original GitHub issue

Just installed postgres with default settings. Created this config:

{
  "defaultEnv": "local",
  "local": {
    "driver": "pg",
    "user": "postgres",
    "password": [my password],
    "host": "localhost",
    "database": "identity",
    "schema": "public"
  }
}

Then tried running

db-migrate db:create identity

.

Got error:

[INFO] Detected and using the projects local version of db-migrate. ‘D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate\index.js’ [INFO] Using local settings: { driver: ‘pg’, user: ‘postgres’, password: ‘******’, host: ‘localhost’, database: ‘identity’, schema: ‘public’ } [INFO] require: db-migrate-pg [INFO] connecting [INFO] connected [SQL] CREATE DATABASE “identity” [ERROR] error: database “identity” does not exist at Connection.parseE (D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate-pg\node_modules\pg\lib\connection.js:539:11) at Connection.parseMessage (D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate-pg\node_modules\pg\lib\connection.js:366:17) at Socket.<anonymous> (D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate-pg\node_modules\pg\lib\connection.js:105:22) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:153:18) at Socket.Readable.push (_stream_readable.js:111:10) at TCP.onread (net.js:531:20)

Tried taking out “database” “identity” from config, and got:

[INFO] Detected and using the projects local version of db-migrate. ‘D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate\index.js’ [INFO] Using local settings: { driver: ‘pg’, user: ‘postgres’, password: ‘******’, host: ‘localhost’, schema: ‘public’ } [INFO] require: db-migrate-pg [INFO] connecting [INFO] connected [SQL] CREATE DATABASE “identity” [ERROR] error: database “savel” does not exist at Connection.parseE (D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate-pg\node_modules\pg\lib\connection.js:539:11) at Connection.parseMessage (D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate-pg\node_modules\pg\lib\connection.js:366:17) at Socket.<anonymous> (D:\Development\friendswithgoals\databases\identity\node_modules\db-migrate-pg\node_modules\pg\lib\connection.js:105:22) at emitOne (events.js:77:13) at Socket.emit (events.js:169:7) at readableAddChunk (_stream_readable.js:153:18) at Socket.Readable.push (_stream_readable.js:111:10) at TCP.onread (net.js:531:20)

Migrations seem to be working fine. I was able to manually create db, and run migrations. Just wondering what I’m doing wrong here.

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
LandonSchroppcommented, Nov 22, 2016

For anyone who runs into this, my workaround was to create a separate database_create.json configuration file that looks like this (without a database property):

{
  "defaultEnv": "local",
  "local": {
    "driver": "pg",
    "user": "postgres",
    "password": [my password],
    "host": "localhost",
    "schema": "public"
  }
}

I then run the create command like this:

node_modules/db-migrate/bin/db-migrate --config database_create.json db:create identity
5reactions
AndrewRayCodecommented, Jan 7, 2019

Would love to see this fixed in core, following the docs in order and then trying to create a db leads to this error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: 15: CREATE DATABASE - PostgreSQL
Character set encoding to use in the new database. Specify a string constant (e.g., ... CREATE DATABASE cannot be executed inside a transaction...
Read more >
rake db:create throws "database does not exist" error with ...
I think that is not it: I am using postgresql "peer" authentication method; anyway, just in case, I also added username and password...
Read more >
Granting a user account permission to create databases in ...
After entering new password for postgres user (special kind of user on PostgreSQL), ... it owns or has specific access to (like databases...
Read more >
How to create a PostgreSQL database and users using psql ...
SUMMARY: This article covers the steps for creating new databases and users in PostgreSQL using both psql and pgAdmin: 1. Using psql.
Read more >
How to easily create a Postgres database in Docker
In this blog post we will take a quick look at what Docker is and how easy it is to run a database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found