如何使用sequelize-typescript
创建以下复合主键(使用sqlite) ?
CREATE TABLE files(
`hash` VARCHAR(255) NOT NULL UNIQUE,
`filePath` VARCHAR(255) NOT NULL UNIQUE,
PRIMARY KEY(hash, filePath)
);
第二次插入hash
失败:
@Table({
tableName: 'files'
})
class File extends Model {
@PrimaryKey
@Column({
unique: true,
allowNull: false,
})
hash!: string
@PrimaryKey
@Column({
unique: true,
allowNull: false,
})
filePath!: string
}
我刚刚发现我必须删除两个unique: true,
声明。现在,sql和行为符合预期。