migrate.js 819 B

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Configuration file for migrate-mongo
  3. * @see https://github.com/seppevs/migrate-mongo
  4. *
  5. * @author Yuki Takei <yuki@weseek.co.jp>
  6. */
  7. require('module-alias/register');
  8. function getMongoUri(env) {
  9. return env.MONGOLAB_URI // for B.C.
  10. || env.MONGODB_URI // MONGOLAB changes their env name
  11. || env.MONGOHQ_URL
  12. || env.MONGO_URI
  13. || ((env.NODE_ENV === 'test') ? 'mongodb://localhost/growi_test' : 'mongodb://localhost/growi');
  14. }
  15. const mongoUri = getMongoUri(process.env);
  16. const match = mongoUri.match(/^(.+)\/([^/]+)$/);
  17. module.exports = {
  18. mongoUri,
  19. mongodb: {
  20. url: match[0],
  21. databaseName: match[2],
  22. options: {
  23. useNewUrlParser: true, // removes a deprecation warning when connecting
  24. },
  25. },
  26. migrationsDir: 'src/migrations/',
  27. changelogCollectionName: 'migrations',
  28. };