Skip to content

Instantly share code, notes, and snippets.

@chukwuemekachm
Created January 30, 2019 15:12
Show Gist options
  • Save chukwuemekachm/6af12336e45bbe1126e911918fc71533 to your computer and use it in GitHub Desktop.
Save chukwuemekachm/6af12336e45bbe1126e911918fc71533 to your computer and use it in GitHub Desktop.
Create review migration file for Introduction to sequelize tutorial.
'use strict';
module.exports = {
up: (queryInterface, Sequelize) =>
queryInterface.createTable('Reviews', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
title: {
allowNull: false,
type: Sequelize.STRING,
},
review: {
allowNull: false,
type: Sequelize.STRING,
},
bookId: {
allowNull: false,
type: Sequelize.INTEGER,
onDelete: 'CASCADE',
references: {
model: 'Books',
key: 'id',
as: 'bookId',
},
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
}),
down: queryInterface => queryInterface.dropTable('Reviews'),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment