如何利用node-migrate将mongo脚本文件迁移到未使用实用程序启动的数据库?

如上所述,我正在尝试使用node-migrate(npm软件包,github:https://github.com/tj/node-migrate)在mongo实例上执行预先存在的mongoscripts。我需要使用它来处理CI / CD和网络限制,并改进开发过程以减少干扰。

到目前为止,我有一个mongo-state-store,通常在github仓库中引用。这将跟踪数据库集合中的更改,而不是migrationfile。

我有一个概念松散的迁移功能,可以从目录中加载文件,并一次执行一个文件。 [包含]

我还创建了一个db对象,每个迁移文件都会使用该db对象(这将有助于简化部署)。

关于将其捆绑在一起的任何建议。


    function migrate() {
      console.log("Made it to start migrate funct.")
      node_migrate.load({
        stateStore: new customStateStorage(),migrationsDirectory: migrationsDir
      },function (err,set) {
        fs.readdir(migrationsDir,(err,files) => {
          files.forEach(file => {
            set.addMigration(new Migration(file,up,down))
          });
        });
        if (err) {
          console.log('Error',err);
          throw err
        }
        set.up(function (err) {
          if (err) {
            throw err
          }
          console.log('migrations successfully ran')
        })
      })
    }

hjfyl 回答:如何利用node-migrate将mongo脚本文件迁移到未使用实用程序启动的数据库?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3093003.html

大家都在问