Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js sync({force:true})保留过时的模型架构_Node.js_Postgresql_Sequelize.js - Fatal编程技术网

Node.js sync({force:true})保留过时的模型架构

Node.js sync({force:true})保留过时的模型架构,node.js,postgresql,sequelize.js,Node.js,Postgresql,Sequelize.js,我的nodejs/sequelizejs(5.7.6)/postgres(11.2)应用程序有一个socketlist模型,最近更新如下: const SocketList = db.define('socketlist', { user_ids: {type: Sql.ARRAY(Sql.INTEGER), }, fort_token: { type: Sql.STRING }, server_id: {type: Sql.ST

我的nodejs/sequelizejs(5.7.6)/postgres(11.2)应用程序有一个socketlist模型,最近更新如下:

const SocketList = db.define('socketlist', {
    user_ids: {type: Sql.ARRAY(Sql.INTEGER),
    },
    fort_token: { 
      type: Sql.STRING      
    },
    server_id: {type: Sql.STRING
    },
}, {
    timestamps: false,
    indexes: [
          {
            fields: ['fort_token']
          },
          {
            fields: ['server_id']
          },
        ]   
});
我正在使用
sync
创建数据库表:

db.sync({force:true})
    .then((res) => {
        console.log("db done!");
        console.log(res);  
    }); //create db 
问题是创建的
socketlist
表仍然基于已更新的旧模式,我不知道
sync
缓存过时模式代码的位置。我试图删除整个数据库或表,但结果总是一样的——旧的和过时的模式。到目前为止,
sync
一直工作正常。这是一个带有
sequelizejs
的bug吗?代码有什么问题

另外,
findOne()
也使用过时的模式,如控制台输出所示:

Socketio server is initialized
Executing (default): SELECT "id", "user_id", "socket_id", "event_id", "server_id", "active" FROM "socketlists" AS "socketlist" WHERE "socketlist"."fort_token" = '12345678901234567890' LIMIT 1;
我删除并重新安装了续集,问题依然存在

以下是数据库连接:

const Sql = require("sequelize");
const db = new Sql('myDB', 'postgres', `${process.env.DB_PASSWORD}`, {
    host: 'localhost',
    dialect: 'postgres',
    port:5433,
} );
以下是旧的(过时的)SocketList模式:

const Sql = require("sequelize");
//const Op = Sql.Op;
const db = require("../startup/db");
const Joi = require('joi');

const SocketList = db.define('socketlist', {
    id: {type: Sql.INTEGER,
         primaryKey:true,
         autoIncrement: true,
         min: 1
    },
    socket_id: {type: Sql.STRING,
                min: 1
    },
    event_id: {type: Sql.INTEGER,
               min: 1
    },
    server_id: {type: Sql.STRING
    },
    active: {type: Sql.BOOLEAN,
             defaultValue: true,
    },
}, {
    timestamps: false
 }, { 
        indexes: [
          {
            //socket_id
            fields: ['socket_id']
          },
          {
            fields: ['active']
          },
          {
            fields: ['server_id']
          },
          {
            fields: ['event_id']
          },
        ]   
}); 

module.exports.SocketList = SocketList; 

你能发布你的旧模式吗?型号,你能发布完整的数据库连接代码吗?只是在帖子中添加了更多信息。我的错。我发现SocketList是另一个指向过时定义的子目录所必需的。指向当前问题后,问题消失。