Skip to content

Instantly share code, notes, and snippets.

@chukwuemekachm
Created January 30, 2019 15:11
Show Gist options
  • Save chukwuemekachm/e1f6bfb3dceef2e90f3045f1e034ba59 to your computer and use it in GitHub Desktop.
Save chukwuemekachm/e1f6bfb3dceef2e90f3045f1e034ba59 to your computer and use it in GitHub Desktop.
Create book migration file for the Introduction to sequelize course.
'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