Keystonejs just dropped my production database
See original GitHub issueBug 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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@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!
@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.