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.

Keystonejs just dropped my production database

See original GitHub issue

Bug report

Today I ran yarn upgrade-interactive and upgraded the keystone version to the newest. Then I deployed the image and saw this in the logs:

✔ Validated project entry file ./src/index.js
✔ Keystone server listening on port 3000
✔ Initialised Keystone instance
⠧ Connecting to database  knex:query select 1+1 as result undefined +0ms
  knex:bindings [] undefined +0ms
⠏ Connecting to database  knex:query select * from information_schema.tables where table_name = ? and table_schema = ? undefined +566ms
  knex:bindings [ 'User', 'public' ] undefined +565ms
⠹ Connecting to databaseKnex adapter: Dropping database
⠸ Connecting to database  knex:query DROP TABLE IF EXISTS "public"."users" CASCADE undefined +730ms

And it just dropped my entire users table, completely and silently. Thankfully I have database backups, but I still lost 18 hours of data.

Describe the bug

I’m using the tableName property to specify the table name in the database. However, Keystone decided to drop my table without any warnings. One would normally assume that running the program would be a safe operation, but keystone somehow decides to drop an important table during that process.

This is a major design flaw, and I couldn’t get around to understand why would someone drop a database table during the startup sequence.

To Reproduce

Run the keystone instance

Expected behaviour

The database is safe

System information

  • Database: Postgresql

Extra info

Please, with bugs like these hanging around do not call Keystone 5 “Production Ready…” It’s not, and it’s misleading to tell people otherwise.

#1820

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Neo-Zhixingcommented, Dec 16, 2019

@jesstelford @JedWatson Thank you for your support! I believe that with your dedication, Keystone v5 will eventually grow into a robust platform just like its predecessor!

0reactions
jesstelfordcommented, Dec 16, 2019

@Neo-Zhixing We’ve released @keystonejs/adapter-knex@6.1.0 which includes a change to make the check safer.

We’re still working on getting a better fix (there are issues with the first-start developer experience we want to make sure we address too), but at the least this will stop dropping the database except for explicitly setting dropDatabase on the Keystone config object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keystone unexpectedly drop the database before the test ...
I 've just executed the tests. And I lost all my local database data. It seems that this is a problem. I didn't...
Read more >
System Configuration - Keystone 6 Documentation - KeystoneJS
API reference for configuring your Keystone system: Lists, Database, Admin UI, Server, Sessions, GraphQl, Files, Images, and experimental options.
Read more >
Introducing KeystoneJS, the CMS & API Platform for Prisma
The original CMS for Node.js, Keystone takes your schema and gives you a GraphQL API and React-powered Admin UI. It's been re-imagined for ......
Read more >
Create a movie rating app with Keystone.js - LogRocket Blog
Also, the Keystone Admin UI automatically changes based on the schema you define. All data can be created, updated, and deleted via the...
Read more >
Keystone Setup Options
The options for KeystoneJS cover a range of behaviours, from how the ... should have access to production config settings) the dotenv module...
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