import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../utils/sequelize.js';

class BlogPost extends Model {}

BlogPost.init({
  blogId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'blog_id'
  },
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    field: 'user_id'
  },
  title: {
    type: DataTypes.STRING(255),
    allowNull: false},
  content: {
    type: DataTypes.TEXT,
    allowNull: false},
  createdAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    field: 'created_at'
  },
  updatedAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
    field: 'updated_at'
  }
}, {
  sequelize,
  modelName: 'BlogPost',
  tableName: 'blog_post',
  schema: 'community',
  timestamps: true,
  underscored: true});

export default BlogPost;
