User not created when setting up Keystone with Postgres
See original GitHub issueBug report
I tried setting up Keybase following the getting started guide but on npm run dev
it starts keystone but no user is created.
To Reproduce
Steps to reproduce the behaviour. Please provide code snippets or a repository:
- init Keystone
- install a Postgres database
- set the user confirguration for the postgres db
- start the server and see that no user is created
Expected behaviour
The user should be created immediately or there should be a screen that shows to create a user when starting the app like #1782.
Additional context
I tried to debug initial-data.js
and changing following:
to:
const res = await keystone.executeQuery(
`query {
_allUsersMeta {
count
}
}`
)
console.log(res)
// Count existing users
const {
data: {
_allUsersMeta: { count },
},
} = res;
I got following error:
{
errors: [
error: relation "public.User" does not exist
at Connection.parseE (./keystonejs/my-app/node_modules/pg/lib/connection.js:604:13)
at Connection.parseMessage (./keystonejs/my-app/node_modules/pg/lib/connection.js:403:19)
at Socket.<anonymous> (./keystonejs/my-app/node_modules/pg/lib/connection.js:123:22)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
at readableAddChunk (_stream_readable.js:289:11)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23)
From previous event:
at Client_PG._query (./keystonejs/my-app/node_modules/knex/lib/dialects/postgres/index.js:236:12)
at Client_PG.query (./keystonejs/my-app/node_modules/knex/lib/client.js:168:17)
at Runner.query (./keystonejs/my-app/node_modules/knex/lib/runner.js:133:36)
at ./keystonejs/my-app/node_modules/knex/lib/runner.js:39:23
at ./keystonejs/my-app/node_modules/knex/lib/runner.js:253:24
at processImmediate (internal/timers.js:439:21)
From previous event:
at Runner.ensureConnection (./keystonejs/my-app/node_modules/knex/lib/runner.js:251:8)
at Runner.run (./keystonejs/my-app/node_modules/knex/lib/runner.js:25:12)
at Builder.Target.then (./keystonejs/my-app/node_modules/knex/lib/interface.js:15:43) {
message: 'select count(*) from "public"."User" as "t0" where true - relation "public.User" does not exist',
locations: [Array],
path: [Array]
}
],
data: [Object: null prototype] {
_allUsersMeta: [Object: null prototype] { count: null }
}
}
Not sure why.
System:
{
"name": "@keystonejs/example-projects-starter",
"description": "An example KeystoneJS project with a User list and Authentication.",
"private": true,
"version": "5.0.1",
"author": "The KeystoneJS Development Team",
"repository": "https://github.com/keystonejs/keystone.git",
"homepage": "https://github.com/keystonejs/keystone",
"license": "MIT",
"engines": {
"node": ">=8.4.0"
},
"scripts": {
"dev": "cross-env NODE_ENV=development DISABLE_LOGGING=true keystone dev",
"build": "cross-env NODE_ENV=production keystone build",
"start": "cross-env NODE_ENV=production keystone start"
},
"dependencies": {
"@keystonejs/adapter-knex": "^6.1.2",
"@keystonejs/app-admin-ui": "^5.3.0",
"@keystonejs/app-graphql": "^5.0.1",
"@keystonejs/auth-password": "^5.0.1",
"@keystonejs/fields": "^6.0.0",
"@keystonejs/keystone": "^5.3.0",
"cross-env": "^5.2.0"
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Keystone Next not showing database type and always select ...
Clone the Keystone repo and have a look at the examples directory. It's full of very simply starting points that use an SQLite...
Read more >Authentication and Access Control - Keystone 6 Documentation
Learn how to use Keystone's built-in Authentication and Access Control systems.
Read more >Configuring Keystone - OpenStack Docs
To configure the OpenStack services with service users, we need to create a project for all the services, and then users for each...
Read more >Installing KeystoneJS 6, NodeJS, Yarn and PostgreSQL
This video walk you through 1. Installing NodeJS 2. Installing Yarn … Show more. Show more. Key moments. View all. What Is the...
Read more >mmobj command - IBM
Use the mmobj command to modify and change the Object protocol service configuration, and to administer storage policies for Object Storage, unified file...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you try setting the
dropDatabase
flag on the Adapter like this:That should force it to initialise
@timfee - Yeah the docs need to be updated as they don’t really tell you what to do with a postgres database and the directions provided from command line are incorrect; they tell you to run
npx keystone create-tables
but that just spits out that error you got.Instead of doing what the instructions tell you, you’ll need to run
npm run create-tables
oryarn create-tables
. Then you can start up keystone in dev mode and it will create theadmin@example.com
user. The output of the command will tell you what the password is (it’s randomly generated).