Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Add a mirgation in sequelize


//Create a migration in main directory:
npx sequelize-cli migration:generate --name add-title-post-table
//or
npx sequelize-cli migration:create --name add-title-post-table

//Inside migration:
module.exports = {
    up: (queryInterface, Sequelize) => {
        return queryInterface.sequelize.transaction((t) => {
            return Promise.all([
                queryInterface.addColumn('table_name', 'field_one_name', {
                    type: Sequelize.STRING
                }, { transaction: t }),
                queryInterface.addColumn('table_name', 'field_two_name', {
                    type: Sequelize.STRING,
                }, { transaction: t })
            ])
        })
    },

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

//Export migration to sequelize:

npx sequelize-cli db:migrate
Comment

PREVIOUS NEXT
Code Example
Javascript :: animated progress bar cdn 
Javascript :: ContentDocumentLink example in jS 
Javascript :: Node-Red: Bit Switch 
Javascript :: ASPxGridView - How to trigger the CustomButtonCallback event 
Javascript :: reactnative sliding image 
Javascript :: trigger many calls JS 
Javascript :: One component overlapping on other in react.js app 
Javascript :: take money from user and give change as output using javascript 
Javascript :: javascript filtrar array string 
Javascript :: javascript one line if without else 
Javascript :: Error: Node Sass version 7.0.1 is incompatible with ^4.0.0. angular 
Javascript :: router unique validation for mongoose 
Javascript :: loadash 
Javascript :: react native set src absolute path 
Javascript :: int[] arr = new int[5]; for(int i=0; i<arr.length; i++){ arr[i] = i; } for(int i=0; i<arr.length; i++) { System.out.print(arr[i]); } 
Javascript :: Function for masking the character 
Javascript :: @rematch/loading 
Javascript :: typeorm sqlite Using async/await syntax 
Javascript :: how to use sort with tiebreak in js 
Javascript :: vuejs check word is availble in the string or not 
Javascript :: get all keys of nested object json data javascript 
Javascript :: Example of AggregateError in es12 
Javascript :: on click disable esc button using jquery 
Javascript :: import * as stringFunctions from "./string_functions.js"; // add code above this line stringFunctions.uppercaseString("hello"); stringFunctions.lowercaseString("WORLD!"); 
Javascript :: function sleep(delay) { var start = new Date().getTime(); while (new Date().getTime() < start + delay); } 
Javascript :: Learning Arrow function Syntax 
Javascript :: programmatically change mongoose schema enum values 
Javascript :: js Set get elements by array 
Javascript :: getting ad to close jquery 
Javascript :: on change swich 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =