Unable to Start After DB Import (error: relation X already exists)
Hi, I have the same strapi app deployed on multiple environments (local, Heroku, etc) and I’m trying to move the data from one to the other.
I followed this docs [1] (Importing and Exporting Heroku Postgres Databases | Heroku Dev Center) and exported the Postgres database I use for strapi in the Heroku environment, I successfully exported the DB.
After I tried to import the data into the local Postgres database (also referring docs [1]), my local strapi won’t start. (check logs below)
it always shows error: relation X already exists
. X = one of the relations defined
Things I tried & the result
-
(failed) I tried to drop the database then recreate a new one, follow docs [1] to restore, and run strapi local => can’t start, same logs.
-
(failed)
I tried to useheroku pg:pull
method (Push and Pull Databases To and From Heroku | Heroku), to pull data from Heroku to the local DB, the pull process succeed, but the local strapi won’t start (same logs). -
(somewhat successful)
I tried to drop the database => recreate a new one => run npm run develop (start strapi on development env) => strapi initialize the database with tables => then I follow the docs [1] => result: the data partially imported (some type has no data, or partially imported)
Logs
Server wasn't able to start properly.
[2020-11-08T10:32:43.724Z] error error: relation "core_store" already exists
at Parser.parseErrorMessage (/Users/jessinra/Code/Project/skadi/node_modules/pg-protocol/dist/parser.js:278:15)
at Parser.handlePacket (/Users/jessinra/Code/Project/skadi/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/Users/jessinra/Code/Project/skadi/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/Users/jessinra/Code/Project/skadi/node_modules/pg-protocol/dist/index.js:8:42)
at Socket.emit (events.js:314:20)
at addChunk (_stream_readable.js:307:12)
at readableAddChunk (_stream_readable.js:282:9)
at Socket.Readable.push (_stream_readable.js:221:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
From previous event:
at Client_PG._query (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/dialects/postgres/index.js:234:12)
at Client_PG.query (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/client.js:158:17)
at Runner.query (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/runner.js:135:36)
at Runner.<anonymous> (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/runner.js:228:25)
at processImmediate (internal/timers.js:461:21)
From previous event:
at Runner.queryArray (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/runner.js:227:12)
at /Users/jessinra/Code/Project/skadi/node_modules/knex/lib/runner.js:37:25
From previous event:
at Runner.run (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/runner.js:25:16)
at SchemaBuilder.Target.then (/Users/jessinra/Code/Project/skadi/node_modules/knex/lib/interface.js:14:43)
Describe the bug
Can’t run strapi after database import
Steps to reproduce the behavior
- export (dump) strapi database from heroku
- import dump into strapi database
- run
npm run develop
/ start
Expected behavior
Strapi runs successfully, all data loaded successfully
Screenshots
System
-
Node.js version: v14.11.0
-
NPM version: 6.14.8
-
Strapi version: 3.2.5
-
Database: postgres
-
Operating system: ubuntu 18.04
-
Other dependencies (package.json)
"knex": "<0.20.0",
"node-fetch": "^2.6.1",
"patch-package": "^6.2.2",
"pg": "^8.3.3",
"sqlite3": "latest",
"strapi": "3.2.5",
"strapi-admin": "3.2.5",
"strapi-connector-bookshelf": "3.2.5",
"strapi-plugin-content-manager": "3.2.5",
"strapi-plugin-content-type-builder": "3.2.5",
"strapi-plugin-documentation": "3.2.5",
"strapi-plugin-email": "3.2.5",
"strapi-plugin-graphql": "3.2.5",
"strapi-plugin-upload": "3.2.5",
"strapi-plugin-users-permissions": "3.2.5",
"strapi-provider-upload-cloudinary": "3.2.5",
"strapi-utils": "3.2.5"
really appreciate if someone could reach out soon
thank you very much in advance!