text: 'use strict';
  
  module.exports = {
    up: async (queryInterface, DataTypes) => {
      await queryInterface.createTable('ExpenseAttachedFiles', {
        id: {
          type: DataTypes.INTEGER,
          primaryKey: true,
          autoIncrement: true,
        },
        ExpenseId: {
          type: DataTypes.INTEGER,
          references: { key: 'id', model: 'Expenses' },
          onDelete: 'CASCADE',
          onUpdate: 'CASCADE',
          allowNull: false,
        },
        CreatedByUserId: {
          type: DataTypes.INTEGER,
          references: { key: 'id', model: 'Users' },
          onDelete: 'SET NULL',
          onUpdate: 'CASCADE',
          allowNull: true,
        },
        url: {
          type: DataTypes.STRING,
          allowNull: false,
        },
        createdAt: {
          type: DataTypes.DATE,
          defaultValue: DataTypes.NOW,
          allowNull: false,
        },
        updatedAt: {
          type: DataTypes.DATE,
          defaultValue: DataTypes.NOW,
          allowNull: false,
        },
      });
  
      await queryInterface.addIndex('ExpenseAttachedFiles', ['ExpenseId']);
    },
  
    down: async queryInterface => {
      await queryInterface.dropTable('ExpenseAttachedFiles');
    },
  };
  