序列化PostgreSQL索引创建错误

时间:2019-02-14 02:00:13

标签: node.js postgresql sequelize.js

我正在尝试使用Sequelize在PostgreSQL中创建一个名为Post的表。我有以下代码来生成表:

const Post = sequelize.define('post', {
  community: Sequelize.STRING,
  block: Sequelize.INTEGER,
  fullPermlink: {
    type: Sequelize.STRING,
    primaryKey: true
  },
  featured: Sequelize.BOOLEAN,
  featurer: Sequelize.STRING,
  pinned: Sequelize.BOOLEAN
},{
  indexes:[
    {
      unique: false,
      fields:['block']
    }
  ]
});

运行此命令,数据库将正确地为block列创建索引,但由于某种原因,它还会尝试将indexes创建为一行本身。这是启用日志记录后提供的日志:

Executing (default): CREATE INDEX "posts_block" ON "posts" ("block")
Executing (default): CREATE TABLE IF NOT EXISTS "pinnedposts" ("id"   SERIAL , "community" VARCHAR(255), "fullPermlink" VARCHAR(255), "indexes" [object Object], "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
Unhandled rejection SequelizeDatabaseError: syntax error at or near "["

这对我来说似乎是一个很奇怪的错误,感谢您的提前帮助!

0 个答案:

没有答案