Untitled
unknown
plain_text
2 years ago
940 B
10
Indexable
//blog_posts
module.exports = {
up: async (QueryInterface, Sequelize) => {
await QueryInterface.createTable('blog_posts', {
id: {
allowNull: false,
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
title: {
type: Sequelize.STRING,
allowNull: false
},
content: {
allowNull: false,
type: Sequelize.STRING(255)
},
userId: {
type: Sequelize.INTEGER,
field: 'user_id',
references: {
model: 'users',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
published: {
type: Sequelize.DATE,
allowNull: true,
},
updated: {
type: Sequelize.DATE,
allowNull: true,
},
});
},
down: async (QueryInterface, _Sequelize) => {
await QueryInterface.dropTable('blog_posts');
},
};Editor is loading...
Leave a Comment