Duffer Derek

Current Path : /var/www/api-mk-planner.bitkit.dk/httpdocs/Backend/src/database/models/
Upload File :
Current File : /var/www/api-mk-planner.bitkit.dk/httpdocs/Backend/src/database/models/subTasksComments.js

import Sequelize from "sequelize";
import dbConnection from "../config/database.js";
import files from "./files.js";

const sequelize = dbConnection;

const subTasksComments = sequelize.define(
  "subtask_comments",
  {
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: Sequelize.INTEGER,
    },
    sub_task_id: {
      type: Sequelize.BIGINT,
      allowNull: true,
    },
    comments: {
      type: Sequelize.STRING(255),
      allowNull: false,
    },
    file_item_id: {
      type: Sequelize.BIGINT,
      allowNull: true,
    },
    created_at: {
      allowNull: false,
      type: Sequelize.DATE,
    },
    updated_at: {
      allowNull: false,
      type: Sequelize.DATE,
    },
    item_id: {
      type: Sequelize.BIGINT,
      allowNull: true,
    },
  },
  {
    tableName: "subtask_comments",
    timestamps: true, // Enable timestamps
    updatedAt: "updated_at", // Customize the updatedAt column name
    createdAt: "created_at", // Customize the createdAt column name
  }
);
files.belongsTo(subTasksComments, {
  foreignKey: "item_id",
  targetKey: "id",
});
subTasksComments.hasMany(files, {
  foreignKey: "item_id",
  sourceKey: "id",
});

export default subTasksComments;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists