migrate.js 782 B

1234567891011121314151617181920212223242526272829
  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. function getMongoUri(env) {
  8. return env.MONGOLAB_URI || // for B.C.
  9. env.MONGODB_URI || // MONGOLAB changes their env name
  10. env.MONGOHQ_URL ||
  11. env.MONGO_URI ||
  12. ((env.NODE_ENV === 'test') ? 'mongodb://localhost/growi_test' : 'mongodb://localhost/growi');
  13. }
  14. const mongoUri = getMongoUri(process.env);
  15. const match = mongoUri.match(/^(.+)\/([^/]+)$/);
  16. module.exports = {
  17. mongoUri,
  18. mongodb: {
  19. url: match[1],
  20. databaseName: match[2],
  21. options: {
  22. useNewUrlParser: true, // removes a deprecation warning when connecting
  23. },
  24. },
  25. migrationsDir: 'src/migrations/',
  26. changelogCollectionName: 'migrations'
  27. };