我试图将我的 Sails JS 应用程序部署到标准的 Ubuntu 14.04.3 VM 上。
现在,我无法将 SailsJS 实例与 PostgreSQL 服务器实例连接起来。SailsJS 服务器和 PostgreSQL 服务器都在同一个 VM 中运行。
我从 Sails 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'
};
我看不出我做错了什么。似乎我的 SailsJS 模型没有被翻译成 PostgreSQL 表,我不知道为什么。任何帮助是极大的赞赏!