JavaScript
Node.js
Sails.js

Sails.jsでmigrateの設定を永続的に行う方法

More than 3 years have passed since last update.

「sails lift」した際に毎回次のような中断(interruption)が入って煩わしい。

Excuse my interruption, but it looks like this app

does not have a project-wide "migrate" setting configured yet.
(perhaps this is the first time you're lifting it with models?)

In short, this setting controls whether/how Sails will attempt to automatically
rebuild the tables/collections/sets/etc. in your database schema.
You can read more about the "migrate" setting here:
http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html?q=migrate

In a production environment (NODE_ENV==="production") Sails always uses
migrate:"safe" to protect inadvertent deletion of your data.
However during development, you have a few other options for convenience:

1. safe - never auto-migrate my database(s). I will do it myself (by hand)
2. alter - auto-migrate, but attempt to keep my existing data (experimental)
3. drop - wipe/drop ALL my data and rebuild models every time I lift Sails

What would you like Sails to do?

info: To skip this prompt in the future, set `sails.config.models.migrate`.
info: (conventionally, this is done in `config/models.js`)

warn: ** DO NOT CHOOSE "2" or "3" IF YOU ARE WORKING WITH PRODUCTION DATA **

prompt: ?:

マイグレーションをどうするかの設定がされてないので、それをどうするか聞かれている。

設定方法はここに書かれている通り、次の2通り:


  • 環境変数でNODE_ENVの値をproductionに設定しておけば、毎回「safe(自動マイグレートなし)」で実行される。

  • config/models.jsでmigrateの値をsafeかalterかdropに設定しておけば、毎回そのモードで実行される。

以上、英語をちゃんと読まずにエラーメッセージでググった人向けの情報(←me)でした。