Database 如何同步postgresql schema的表-Sequelize ORM
我的博士后中有两个模式Database 如何同步postgresql schema的表-Sequelize ORM,database,postgresql,sequelize.js,Database,Postgresql,Sequelize.js,我的博士后中有两个模式 公共//默认模式 第一用户 现在我在两个模式中都有相同的表 我更改了表结构,所以现在要运行同步, 我使用以下方式同步表: const db = new Sequelize(postgres_db, postgres_user, postgres_pwd, { host: postgres_host, port: 5432, dialect: 'postgres', logging: false, }); db.sync().then(() => {
const db = new Sequelize(postgres_db, postgres_user, postgres_pwd, {
host: postgres_host,
port: 5432,
dialect: 'postgres',
logging: false,
});
db.sync().then(() => {
console.log('Table Synced');
}, (err) => {
console.log(err);
});
运行此命令后,公共模式内的表结构已成功更改,但我的第一个用户模式的表结构保持不变
如何解决这个问题
注意:我不想丢失表中的数据。您可以尝试创建表作为表查询
首先将table\u user.tableName创建为table public.tableName代码>最终使用sequelize迁移实现了这一点
如果由于缺少Typescript支持而无法使用Sequelize迁移,您可以使用易于使用的Migra。