在 Sails.js 中为所有模型禁用数据库迁移 [英] Disable database migrations in Sails.js for all models

查看:33
本文介绍了在 Sails.js 中为所有模型禁用数据库迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚如何在 Sails.js 中为模型禁用自动数据库迁移.

I'm trying to figure out how to disable automatic database migrations for Models in Sails.js.

我知道你可以在模型中设置 migrate: 'safe',但是有没有办法为所有模型指定这个?

I know you can set migrate: 'safe' in the model, but is there a way to specify this for all models?

推荐答案

其实是有办法的.ORM 钩子 正在从 sails.config.model,所以你所要做的就是用以下内容创建config/model.js:

Actually, there is a way to do it. ORM hooks are getting defaults from sails.config.model, so all you have to do is to create config/model.js with the following content:

module.exports.model = {
  migrate: 'safe'
}

在此之后,迁移将不会在 sails lift 上运行,但它们仍然会在您创建文档后应用,例如.

After this the migrations won't be running upon sails lift, but they will still be applied once you create a document, for example.

这篇关于在 Sails.js 中为所有模型禁用数据库迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆