93 lines
2.3 KiB
JavaScript
93 lines
2.3 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await queryInterface.createTable('documents', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
allowNull: false
|
|
},
|
|
filename: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
original_filename: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
file_path: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
file_type: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
file_size: {
|
|
type: DataTypes.BIGINT,
|
|
allowNull: false
|
|
},
|
|
content: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true
|
|
},
|
|
extracted_text: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true
|
|
},
|
|
embeddings: {
|
|
type: DataTypes.JSONB,
|
|
allowNull: true
|
|
},
|
|
metadata: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: {},
|
|
allowNull: false
|
|
},
|
|
is_indexed: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: false,
|
|
allowNull: false
|
|
},
|
|
indexing_status: {
|
|
type: DataTypes.ENUM('pending', 'processing', 'completed', 'failed'),
|
|
defaultValue: 'pending',
|
|
allowNull: false
|
|
},
|
|
tags: {
|
|
type: DataTypes.ARRAY(DataTypes.STRING),
|
|
defaultValue: [],
|
|
allowNull: false
|
|
},
|
|
category: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true
|
|
},
|
|
created_at: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW
|
|
},
|
|
updated_at: {
|
|
type: DataTypes.DATE,
|
|
allowNull: false,
|
|
defaultValue: DataTypes.NOW
|
|
}
|
|
});
|
|
|
|
// Create indexes
|
|
await queryInterface.addIndex('documents', ['file_type']);
|
|
await queryInterface.addIndex('documents', ['is_indexed']);
|
|
await queryInterface.addIndex('documents', ['indexing_status']);
|
|
await queryInterface.addIndex('documents', ['category']);
|
|
await queryInterface.addIndex('documents', ['tags']);
|
|
await queryInterface.addIndex('documents', ['created_at']);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.dropTable('documents');
|
|
}
|
|
};
|