0

I have a db which was created like this:

const UserModel = db.define('user', {
  id: { type: Sequelize.STRING, unique: true, primaryKey: true },
  firstName: {
  type: Sequelize.STRING,
 },
 lastName: { type: Sequelize.STRING },
 username: {
  type: Sequelize.STRING,
    unique: {
    args: true,
    msg: USERNAME_IS_TAKEN,
 },
}

UserModel.belongsToMany(UserModel, { as: 'followingUsers', through: 'Relations', foreignKey: 'followerUserId' });

And then run:

db.sync({ force: true });

Can I just start using migrations to add a column?

sequelize migration:create
perrosnk
  • 835
  • 2
  • 13
  • 23
  • yes you should create new migration – Shubham Apr 13 '20 at 18:55
  • Keep in mind that after you added a new column in your model you cannot call the sync and execute a migration that creates the column on a new database because the migration will fail to create already existing column (created by the sync call). – Anatoly Apr 13 '20 at 20:23
  • I am looking for a way to start doing changes in my db, without calling sync and lose my data. – perrosnk Apr 13 '20 at 21:21

0 Answers0