【问题标题】:how to run knex migrations如何运行 knex 迁移
【发布时间】:2013-11-09 22:07:49
【问题描述】:

我正在玩 Ghost 博客平台https://github.com/TryGhost/Ghost/issues/769。它使用 knex 模块让 nodejs 与 sqlite3 数据库交互。回滚的迁移看起来像这样。我想知道是否有办法从 sqlite3 控制台运行它,或者如果我想回滚迁移,我该怎么做?

down = function () {
    return when.all([
        knex.schema.dropTableIfExists('posts_tags'),
        knex.schema.dropTableIfExists('roles_users'),
        knex.schema.dropTableIfExists('permissions_users'),
        knex.schema.dropTableIfExists('permissions_roles'),
        knex.schema.dropTableIfExists('users')

    ]).then(function () {
        return when.all([
            knex.schema.dropTableIfExists('roles'),
            knex.schema.dropTableIfExists('settings'),
            knex.schema.dropTableIfExists('permissions'),
            knex.schema.dropTableIfExists('tags'),
            knex.schema.dropTableIfExists('posts')
        ]);
    });
};

exports.up   = up;
exports.down = down;
exports.constraints = constraints;

【问题讨论】:

    标签: node.js sqlite ghost-blog


    【解决方案1】:

    目前没有办法通过命令行运行它。我们保留了向上和向下迁移的定义,以防我们将来需要它们,但目前还没有使用它们。

    Ghost 中的迁移系统目前也在重写,然后在 0.4 版中完成任何实际迁移。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 2015-11-11
      • 2016-11-02
      • 2017-12-21
      • 2021-05-11
      相关资源
      最近更新 更多