问题:无法提升sails项目(最初为mysql编写,将适配器和设置更改为postgres)
错误:
info: ·• Auto-migrating... (drop)
error: A hook (`orm`) failed to load!
error:
error: error: syntax error at or near "ON"
at Connection.parseE (*/node_modules/pg/lib/connection.js:569:11)
at Connection.parseMessage (*/node_modules/pg/lib/connection.js:396:17)
at Socket.<anonymous> (*/node_modules/pg/lib/connection.js:132:22)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
error: Could not load Sails app.适配器响应:
错误详细信息:
{ error: syntax error at or near "ON"
at Connection.parseE (*/node_modules/pg/lib/connection.js:569:11)
at Connection.parseMessage (*/node_modules/pg/lib/connection.js:396:17)
at Socket.<anonymous> (*/node_modules/pg/lib/connection.js:132:22)
at Socket.emit (events.js:189:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at Socket.Readable.push (_stream_readable.js:220:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
name: 'error',
length: 92,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '191',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1134',
routine: 'scanner_yyerror' }我尝试过更改数据存储设置,尝试本地主机和远程部署,用户名和密码,更改角色,数据库权限。但似乎什么都解决不了这个问题。
我是不是遗漏了什么?
adapter: 'sails-postgresql',
url: 'postgresql://postgres:postgres@localhost:5432/postgres',一种型号:
module.exports = {
tableName: 'roles',
attributes: {
name: {
type: "string",
required: true,
columnType: "varchar(255) COLLATE utf8_unicode_ci NOT NULL"
},
company_id: {
type: "number",
required: true,
columnType: "int(11) NOT NULL"
},
mobile_user: {
type: "number",
required: false,
defaultsTo: 0,
columnType: "tinyint(1) NOT NULL DEFAULT '0'"
},
enforcement: {
type: "number",
required: false,
defaultsTo: 0,
columnType: "tinyint(1) NOT NULL DEFAULT '0'"
},
}
};我正在将数据库从mysql迁移到postgre。有谁面临同样的问题吗?
发布于 2019-02-19 12:17:58
在尝试了更多的设置和更改之后。我发现这个问题是由模型引起的,即通过将模型的columnType中提到的所有数据类型和条件从MySQL更改为PostgresSQL,就像一种魅力。
示例: tinyint(1) -> smallint,删除排序条件等
https://stackoverflow.com/questions/54765368
复制相似问题