O
O
ovseyasha2022-01-17 09:53:43
PostgreSQL
ovseyasha, 2022-01-17 09:53:43

How to do nestjs migrations with postgresql and sequelize?

I'm used to doing everything according to guides and I just can't find a normal explanation: how to do migrations using nest.js and sequelize. Please explain or help with a link to a good article.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Kvartsov, 2022-02-04
@kolesov_prod

npx sequelize-cli migration:create --name migration-name
20220204133519-migration-name.js:

module.exports = {
  async up (queryInterface, Sequelize) {
    await queryInterface.addColumn("table", "field", {
      type: Sequelize.INTEGER
      defaultValue: 0
    })
  },

  async down (queryInterface, Sequelize) {
    await queryInterface.removeColumn("table", "field");
  }
};

npx sequelize-cli db:migrate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question