Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
940 B
5
Indexable
Never
//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');
  },
};
Leave a Comment