Add data in Sequelize migration script?

后端 未结 4 1933

How can I add data to a table in a Sequelize migration script? This is what I got:

module.exports = {
up: function(migration, DataTypes, done) {
    migration.cr         


        
4条回答
  •  走了就别回头了
    2021-02-07 07:37

    In the latest version of sequelize this has changed and it should now be

    migration.createTable(
        'Person',
        {
            name: DataTypes.STRING,
            age: DataTypes.INTEGER,
        }
    ).then(function () {
        migration.sequelize.query("insert into person (name, age) values ('Donald Duck', 60)");
        done();
    });
    

提交回复
热议问题