Im試圖將我的Sails JS應用程序部署到標準的Ubuntu 14.04.3 VM上。SailsJS/Waterline無法在Postgres中創建模型
現在,我無法連接我的SailsJS實例與PostgreSQL服務器實例。 SailsJS服務器和PostgreSQL服務器都運行在同一個VM中。
我得到以下輸出從我的帆JS日誌:
MySailsServer-0 Sending 500 ("Server Error") response:
Error (E_UNKNOWN) :: Encountered an unexpected error
error: relation "recording" does not exist
at Connection.parseE (/home/vmuser/MySailsServer/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:539:11)
at Connection.parseMessage (/home/vmuser/MySailsServer/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:366:17)
at Socket.<anonymous> (/home/vmuser/MySailsServer/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:105:22)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20)
它好像我Recording
模型未能在數據庫中創建。 我檢查了Postgre日誌以獲取更多信息。下面是cat /var/log/postgresql/postgresql-9.3-main.log
輸出:
2015-10-17 14:46:13 CDT ERROR: relation "recording" does not exist at character 491
2015-10-17 14:46:13 CDT STATEMENT: SELECT "recording"."startTime", "recording"."endTime", "recording"."filename", "recording"."id", "recording"."createdAt", "recording"."updatedAt", "recording"."section", "__section"."startTime" AS "section___startTime", "__section"."endTime" AS "section___endTime", "__section"."name" AS "section___name", "__section"."id" AS "section___id", "__section"."createdAt" AS "section___createdAt", "__section"."updatedAt" AS "section___updatedAt", "__section"."course" AS "section___course" FROM "recording" AS "recording" LEFT OUTER JOIN "section" AS "__section" ON "recording"."section" = "__section"."id" LIMIT 30 OFFSET 0
上爲什麼沒有我所api/models/
下申報的車型被製作成PostgreSQL的表的任何線索?
這裏是我的配置有config/connections.js
下:
postgresqlServer: {
adapter: 'sails-postgresql',
host: 'localhost',
user: <username>,
password: <password>,
database: <db_name>,
schema: true
}
在config/models.js
我已經把:
module.exports.models = {
connection: 'postgresqlServer',
migrate: 'alter'
};
我看不出有什麼Im做不正確。看起來我的SailsJS模型沒有被翻譯成PostgreSQL表格,我不知道爲什麼。 任何幫助,非常感謝!
嘗試'帆船升降機--silly'來查看是否在建造模型時記錄任何有趣的事情。另外值得注意的是,如果您使用'--prod'標誌,sails總是以安全模式在prod中運行,並且不會將更改遷移到數據庫。 –
@FrederickStark有趣...我認爲用'--prod'至少可以創建表格,如果它們至少沒有創建,但可能不是。任何指定的方式,我希望它與生產配置運行,但也不只是在安全模式?它的初始部署,所以沒有數據丟失。 – sourdesi
不確定。作爲我的構建過程的一部分,我通常在'帆升降機前'運行'帆升降機' –