Files
reason-flow/server/migrations/008_create_training_data.js
T

86 lines
2.2 KiB
JavaScript
Raw Normal View History

2025-11-06 11:08:59 +01:00
const { DataTypes } = require('sequelize');
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('training_data', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false
},
model_version_id: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: 'model_versions',
key: 'id'
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE'
},
data_type: {
type: DataTypes.ENUM('qa_pair', 'plan_pair', 'feedback', 'preference'),
allowNull: false
},
input_text: {
type: DataTypes.TEXT,
allowNull: false
},
output_text: {
type: DataTypes.TEXT,
allowNull: false
},
context: {
type: DataTypes.JSONB,
defaultValue: {},
allowNull: false
},
quality_score: {
type: DataTypes.FLOAT,
allowNull: true
},
is_validated: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
},
validation_notes: {
type: DataTypes.TEXT,
allowNull: true
},
source: {
type: DataTypes.ENUM('expert', 'user', 'generated', 'feedback'),
allowNull: false
},
metadata: {
type: DataTypes.JSONB,
defaultValue: {},
allowNull: false
},
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('training_data', ['model_version_id']);
await queryInterface.addIndex('training_data', ['data_type']);
await queryInterface.addIndex('training_data', ['is_validated']);
await queryInterface.addIndex('training_data', ['source']);
await queryInterface.addIndex('training_data', ['quality_score']);
await queryInterface.addIndex('training_data', ['created_at']);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('training_data');
}
};