module.exports = (sequelize, DataTypes) => {
  const task = sequelize.define(
    "task",
    {
      id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      flow_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        references: {
          model: "flow",
          key: "id",
        },
      },
      action_type: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      input_data: {
        type: DataTypes.TEXT,
        allowNull: false,
      },
      order_index: {
        type: DataTypes.INTEGER,
        allowNull: false,
      },
      created_at: {
        type: DataTypes.DATE,
        defaultValue: DataTypes.NOW,
      },
    },
    {
      timestamps: false,
      freezeTableName: true,
      tableName: "task",
    }
  );
  return task;
};
