为什么我不能通过多个活动连接来同步续集?

时间:2019-03-26 01:03:49

标签: postgresql heroku sequelize.js

我试图在sequelize上更新某些模型,当我运行sequelize.sync程序时会抛出错误

  

错误:重复的键值违反了唯一约束“ pg_type_typname_nsp_index”

  

“密钥(typname,typnamespace)=(person_id_seq,2200)已经存在。”

我通过pgadmin4关闭了postgres连接,并重新运行了脚本,该脚本成功更新/创建了模型定义。

我放下了表并尝试重新创建它们,并确保每次我有多个连接时它都会失败。

我仅使用postgres instance on heroku with the hobby plan,所以不确定是否存在限制

型号:

db.Person = sequelize.define('person', {
    id: {
        type: Sequelize.BIGINT,
        primaryKey: true, 
        autoIncrement: true,
        allowNull: false
    },
    first_name: {
        type: Sequelize.STRING,
        allowNull: false
    },
    last_name: {
        type: Sequelize.STRING,
        allowNull: false
    },
    email: {
        type: Sequelize.STRING,
        unique: true,
        allowNull: false
    },
    passwordHash: {
        type: Sequelize.TEXT,
        allowNull: false
    }
},
{
    underscored: true,
    freezeTableName: true
});

db.Ingredient = sequelize.define('ingredient', {
    id: {
        type: Sequelize.BIGINT,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false,
    },
    name: {
        type: Sequelize.TEXT,
        allowNull: false
    }
},
{
    underscored: true,
    freezeTableName: true
});

db.PersonIngredient = sequelize.define('person_ingredient', {
    id: {
        type: Sequelize.BIGINT,
        primaryKey: true, 
        autoIncrement: true,
        allowNull: false
    },
    custom_ingredient: {
        type: Sequelize.TEXT
    }
},
{
    underscored: true,
    freezeTableName: true
});

0 个答案:

没有答案