Spaces:
Runtime error
Runtime error
| import { | |
| DataTypes, | |
| Model, | |
| InferAttributes, | |
| InferCreationAttributes, | |
| CreationOptional, | |
| } from 'sequelize'; | |
| import { sequelize } from './index'; | |
| import { ErrorLogInterface } from '../shared/interfaces/errorLog.interface'; | |
| import Invoice from './invoice'; | |
| class ErrorLog extends Model<ErrorLogInterface>implements ErrorLogInterface { | |
| declare id?: CreationOptional<number>; | |
| declare invoice_id?: number; | |
| declare error_type: string; | |
| declare error_details: string; | |
| } | |
| ErrorLog.init( | |
| { | |
| id: { | |
| type: DataTypes.INTEGER, | |
| primaryKey: true, | |
| autoIncrement: true | |
| }, | |
| invoice_id: { | |
| type: DataTypes.INTEGER, | |
| references: { | |
| model: Invoice, | |
| key: 'id' | |
| }, | |
| onDelete: 'CASCADE' | |
| }, | |
| error_type: { | |
| type: DataTypes.STRING | |
| }, | |
| error_details: { | |
| type: DataTypes.TEXT | |
| }, | |
| }, | |
| { | |
| sequelize, | |
| tableName: 'error_log', | |
| underscored: true, | |
| freezeTableName: true, | |
| timestamps: true, | |
| createdAt: "created_at", | |
| updatedAt: "updated_at" | |
| } | |
| ); | |
| ErrorLog.belongsTo(Invoice, { foreignKey: 'invoice_id' }); | |
| export default ErrorLog | |