trailsjs / trailpack-mongoose

:package: Mongoose.js Trailpack http://mongoosejs.com
MIT License
8 stars 11 forks source link

Error: Migrate must be configured to either "create" or "drop" #12

Closed connor11528 closed 8 years ago

connor11528 commented 8 years ago

This is pretty basic but I would appreciate the help! I create a new application using express 4 and mongoose with trails.js. I got the following error (see below).

I see that I probably need to configure Stores. Where do I do that? I see it in the README but it is not clear to me where the code must go.

I appreciate any direction or help. Happy to submit a PR to clear things up if there is an obvious answer. thank you.

$ node server
error: 
 Error: Migrate must be configured to either "create" or "drop"
    at MongooseTrailpack.validate (/Users/connorleech/Projects/trails-tutorial/node_modules/trailpack-mongoose/index.js:19:13)
    at app.after.then (/Users/connorleech/Projects/trails-tutorial/node_modules/trails/lib/trailpack.js:68:26)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)
    at Function.Module.runMain (module.js:577:11)
    at startup (node.js:159:18)
    at node.js:444:3
error: The application did not boot successfully.
error: Try increasing the loglevel to "debug" to learn more
konstantinzolotarev commented 8 years ago

@connor11528 Actually yes you have to configure store. There is a section about configuration here: https://github.com/trailsjs/trailpack-mongoose#configure-stores

There is option: migrate. You have to set it up to create or drop. You might have alter or not set up at all.

connor11528 commented 8 years ago

Okay cool I see that. Where in my application do I put the code in the "Configure stores" section? Do I configure stores in config/env/production.js? What file stores the Stores configuration.. if that makes sense!

connor11528 commented 8 years ago

Okay my bad. All that needs to happen is edit the stores file in config/database.js. n00b mistake

Default file will look like this:

/**
 * Database Configuration
 * (app.config.database)
 *
 * Configure the ORM layer, connections, etc.
 *
 * @see {@link http://trailsjs.io/doc/config/database}
 */

'use strict'

module.exports = {

  /**
   * Define the database stores. A store is typically a single database.
   *
   * Use the SQLite3 by default for development purposes.
   *
   * Set production connection info in config/env/production.js
   */
  stores: {

    /**
     * Define a store called "local" which uses SQLite3 to persist data.
     *
     * To use this store, uncomment the "sqlitedev" store section below, and
     * run "npm install --save waterline-sqlite3"
     */

    /*
     dev: {
      adapter: require('waterline-sqlite3'),
      migrate: 'alter'
    }
     */
  },

  models: {
    defaultStore: 'dev',
    migrate: 'alter'
  }
}
konstantinzolotarev commented 8 years ago

Yep exactly. it should be into config/database.js or in database section into config/env/{env}.js file. I'll update description in a moment

connor11528 commented 8 years ago

Thank you!