const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const Page = sequelize.define('Page', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  title: { type: DataTypes.STRING(200), allowNull: false },
  slug: { type: DataTypes.STRING(200), allowNull: false, unique: true },
  content: { type: DataTypes.TEXT },
  metaTitle: { type: DataTypes.STRING(200), field: 'meta_title' },
  metaDescription: { type: DataTypes.TEXT, field: 'meta_description' },
  isPublished: { type: DataTypes.BOOLEAN, defaultValue: false, field: 'is_published' },
  sortOrder: { type: DataTypes.INTEGER, defaultValue: 0, field: 'sort_order' },
}, {
  tableName: 'pages',
  timestamps: true,
  underscored: true,
});

module.exports = Page;
