6

I have a local, strapi app (that I have in a git repo) that I want to migrate from using sqlite3 to using mongodb

I have done the following:

  • created a 2nd, temporary, strapi app that is successfully using mongodb from the start (so I have a good mongo instance running locally)

  • copied the database.json content from the temp, working-mongodb, strapi app to my existing one. (made sure was in development and ran development version)

From my existing app (from which I want to use mongodb), I

  • uninstalled:

    • strapi-hook-bookshelf

    • strapi-hook-knex

    • knex

    • sqlite3

  • installed strapi-hook-mongoose

NOTES:

  • the existing app (from which i want to use mongodb) runs successfully if I keep just keep using sqlite3.
  • i created the existing app using the quickstart option

But, I still get this error...terminal output, snippet below

Terminal Output Snippet:

(node:37499) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
(node:37499) UnhandledPromiseRejectionWarning: TypeError: orm.load(...).buildQuery is not a function
    at buildQuery (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-utils/lib/buildQuery.js:122:21)
    at Object.count (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-plugin-users-permissions/config/queries/mongoose.js:18:12)
    at Object.initialize (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-plugin-users-permissions/services/UsersPermissions.js:502:8)
    at module.exports (/Users/monico_a_moreno/source/.../folder-strapi-poc/node_modules/strapi-plugin-users-permissions/config/functions/bootstrap.js:156:65)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:37499) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:37499) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[2019-07-03T18:27:15.985Z] warn The bootstrap function is taking unusually long to execute (3500 miliseconds).
[2019-07-03T18:27:15.986Z] warn Make sure you call it?

    What am I doing wrong?   


Monico Moreno
  • 127
  • 1
  • 8

1 Answers1

4

This is cool! I can answer my own question!

Seriously though, I am answering my own question for the benefit of others that might run into the same issue.

Bottom line: I had the wrong version of strapi-hook-mongoose installed.

Details: When I installed strapi-hook-mongoose, I didn't specify a version, and so, npm installed ^3.0.0-alpha.13, and due to the fact that my existing, strapi project is on the (then) latest v3.0.0-beta.7, it failed to run (gave the error described in the above description).

Solution: Uninstall the package and re-install, explicitly specifying the version

npm i strapi-hook-mongoose@3.0.0-beta.7

Monico Moreno
  • 127
  • 1
  • 8