Created
January 30, 2019 15:11
-
-
Save chukwuemekachm/e1f6bfb3dceef2e90f3045f1e034ba59 to your computer and use it in GitHub Desktop.
Create book migration file for the Introduction to sequelize course.
This file contains hidden or 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) => | |
queryInterface.createTable('Books', { | |
id: { | |
allowNull: false, | |
autoIncrement: true, | |
primaryKey: true, | |
type: Sequelize.INTEGER, | |
}, | |
title: { | |
allowNull: false, | |
type: Sequelize.STRING, | |
}, | |
description: { | |
allowNull: false, | |
type: Sequelize.STRING, | |
}, | |
genre: { | |
type: Sequelize.ENUM, | |
values: [ | |
'Tragedy', | |
'Adventure', | |
'Fiction', | |
'Fable', | |
'Mystery', | |
'Mythology', | |
'Biography', | |
'Memoir', | |
'Essay', | |
'Textbook', | |
], | |
defaultValue: 'Essay', | |
}, | |
isbnNo: { | |
allowNull: false, | |
type: Sequelize.STRING, | |
}, | |
pages: { | |
type: Sequelize.INTEGER, | |
}, | |
createdAt: { | |
allowNull: false, | |
type: Sequelize.DATE, | |
}, | |
updatedAt: { | |
allowNull: false, | |
type: Sequelize.DATE, | |
}, | |
}), | |
down: queryInterface => queryInterface.dropTable('Books'), | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment