Files
reason-flow/server/migrations/007_create_model_versions.js
T

95 lines
2.4 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('model_versions', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
allowNull: false
},
model_name: {
type: DataTypes.STRING,
allowNull: false
},
version: {
type: DataTypes.STRING,
allowNull: false
},
model_type: {
type: DataTypes.ENUM('MODEL1', 'QUERYMODEL'),
allowNull: false
},
base_model: {
type: DataTypes.STRING,
allowNull: false
},
fine_tuning_method: {
type: DataTypes.ENUM('SFT', 'DPO', 'PPO', 'LoRA', 'QLoRA'),
allowNull: true
},
training_data_count: {
type: DataTypes.INTEGER,
defaultValue: 0,
allowNull: false
},
performance_metrics: {
type: DataTypes.JSONB,
defaultValue: {},
allowNull: false
},
is_active: {
type: DataTypes.BOOLEAN,
defaultValue: false,
allowNull: false
},
deployment_status: {
type: DataTypes.ENUM('training', 'testing', 'deployed', 'deprecated'),
defaultValue: 'training',
allowNull: false
},
model_path: {
type: DataTypes.STRING,
allowNull: true
},
hyperparameters: {
type: DataTypes.JSONB,
defaultValue: {},
allowNull: false
},
training_log: {
type: DataTypes.JSONB,
defaultValue: {},
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('model_versions', ['model_name']);
await queryInterface.addIndex('model_versions', ['model_type']);
await queryInterface.addIndex('model_versions', ['is_active']);
await queryInterface.addIndex('model_versions', ['deployment_status']);
await queryInterface.addIndex('model_versions', ['created_at']);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('model_versions');
}
};