问题:无法取消帆项目(最初是为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。有人遇到过同样的问题吗?
答案 0 :(得分:0)
尝试更多设置和更改后。我发现问题是由模型引起的,即,通过将模型的 columnType 中提到的所有数据类型和条件从MySQL更改为PostgresSQL,都可以正常工作。
示例:tinyint(1)-> smallint,删除COLLATE条件等