Created
August 9, 2018 17:25
-
-
Save allaniftrue/9bb312a568eed5aff94b8cf9ad9d679c to your computer and use it in GitHub Desktop.
A sample sequelize migration with default value for timestamps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
module.exports = { | |
up: (queryInterface, Sequelize) => { | |
return queryInterface.createTable("users", { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER | |
}, | |
first_name: { | |
allowNull: false, | |
type: Sequelize.STRING | |
}, | |
last_name: { | |
allowNull: false, | |
type: Sequelize.STRING | |
}, | |
email: { | |
allowNull: false, | |
type: Sequelize.STRING | |
}, | |
password: { | |
allowNull: false, | |
type: Sequelize.STRING | |
}, | |
is_confirmed: { | |
allowNull: false, | |
type: Sequelize.BOOLEAN, | |
defaultValue: false | |
}, | |
created_at: { | |
type: Sequelize.DATE, | |
allowNull: false, | |
defaultValue: Sequelize.literal("NOW()") | |
}, | |
updated_at: { | |
type: Sequelize.DATE, | |
allowNull: false, | |
defaultValue: Sequelize.literal("NOW()") | |
} | |
}); | |
}, | |
down: (queryInterface, Sequelize) => { | |
return queryInterface.dropTable("users"); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment