Skip to content

Instantly share code, notes, and snippets.

@s1moe2
Last active February 4, 2022 17:34
Show Gist options
  • Select an option

  • Save s1moe2/38e6b065f85237ebe48cb9ecc9d10036 to your computer and use it in GitHub Desktop.

Select an option

Save s1moe2/38e6b065f85237ebe48cb9ecc9d10036 to your computer and use it in GitHub Desktop.

Revisions

  1. s1moe2 revised this gist Jul 14, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions 20181118235404-some-migration.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    // NOTE: MySQL does not support transactional DDL (https://dev.mysql.com/doc/internals/en/transactions-notes-on-ddl-and-normal-transaction.html)
    // You should use this with a (cool) DBMS such as PostgreSQL.

    module.exports = {
    up: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
  2. s1moe2 revised this gist Jul 14, 2020. No changes.
  3. s1moe2 created this gist Nov 20, 2018.
    23 changes: 23 additions & 0 deletions 20181118235404-some-migration.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    module.exports = {
    up: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
    return Promise.all([
    queryInterface.addColumn('table_name', 'column_name1', {
    type: Sequelize.STRING
    }, { transaction: t }),
    queryInterface.addColumn('table_name', 'column_name2', {
    type: Sequelize.STRING,
    }, { transaction: t })
    ])
    })
    },

    down: (queryInterface, Sequelize) => {
    return queryInterface.sequelize.transaction((t) => {
    return Promise.all([
    queryInterface.removeColumn('table_name', 'column_name1', { transaction: t }),
    queryInterface.removeColumn('table_name', 'column_name2', { transaction: t })
    ])
    })
    }
    };