Sobes.tech
Junior — Middle

Have you ever worked with database migration systems?

sobes.tech AI

Answer from AI

Yes, experience with database migration systems in Node.js typically involves using tools such as Sequelize, TypeORM, or Knex. These systems allow managing changes to the database schema (creating tables, modifying columns, indexes, etc.) through migration scripts that can be run sequentially, ensuring version control of the database schema.

Example of using migration in Sequelize:

'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('Users', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      name: {
        type: Sequelize.STRING
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('Users');
  }
};

This approach helps keep the database up-to-date and simplifies teamwork on the project.