feat: завершить полную миграцию V1→V2 с модульной архитектурой и документацией
- Завершить миграцию фулфилмента на 100% V2 (удалить legacy компонент) - Создать полную V2 систему для расходников селлера (SellerConsumableInventory) - Автоматическое пополнение инвентаря при статусе DELIVERED - Удалить весь код создания V1 Supply для расходников - Исправить фильтрацию: расходники селлера только на странице consumables - Исправить Organization.inn null ошибку с fallback значениями - Создать документацию V2 систем и отчет о миграции - Обновить import порядок для ESLint совместимости BREAKING CHANGES: V1 система поставок расходников полностью удалена
This commit is contained in:
103
scripts/test-v2-migration.cjs
Normal file
103
scripts/test-v2-migration.cjs
Normal file
@ -0,0 +1,103 @@
|
||||
const { PrismaClient } = require('@prisma/client')
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
// Тестируем V2 систему фулфилмента после переключения
|
||||
async function testV2Migration() {
|
||||
console.log('🔍 ТЕСТИРОВАНИЕ V2 СИСТЕМЫ ФУЛФИЛМЕНТА...')
|
||||
|
||||
try {
|
||||
// 1. Проверяем организацию фулфилмента
|
||||
const fulfillmentOrg = await prisma.organization.findFirst({
|
||||
where: { type: 'FULFILLMENT' },
|
||||
select: { id: true, name: true, inn: true }
|
||||
})
|
||||
|
||||
if (!fulfillmentOrg) {
|
||||
console.log('❌ Организация фулфилмента не найдена')
|
||||
return
|
||||
}
|
||||
|
||||
console.log(`✅ Фулфилмент: ${fulfillmentOrg.name} (${fulfillmentOrg.id})`)
|
||||
|
||||
// 2. Проверяем V2 инвентарь
|
||||
console.log('\n📦 ПРОВЕРКА V2 ИНВЕНТАРЯ...')
|
||||
const inventory = await prisma.fulfillmentConsumableInventory.findMany({
|
||||
where: { fulfillmentCenterId: fulfillmentOrg.id },
|
||||
include: {
|
||||
product: { select: { name: true, article: true } },
|
||||
fulfillmentCenter: { select: { name: true } }
|
||||
}
|
||||
})
|
||||
|
||||
console.log(`📊 V2 Inventory записей: ${inventory.length}`)
|
||||
inventory.forEach((item, i) => {
|
||||
console.log(` ${i+1}. ${item.product.name} - остаток: ${item.currentStock}`)
|
||||
})
|
||||
|
||||
// 3. Проверяем V2 заказы
|
||||
console.log('\n📋 ПРОВЕРКА V2 ЗАКАЗОВ...')
|
||||
const orders = await prisma.fulfillmentConsumableSupplyOrder.findMany({
|
||||
where: { fulfillmentCenterId: fulfillmentOrg.id },
|
||||
include: {
|
||||
items: { include: { product: { select: { name: true } } } },
|
||||
supplier: { select: { name: true } }
|
||||
},
|
||||
orderBy: { createdAt: 'desc' }
|
||||
})
|
||||
|
||||
console.log(`📊 V2 Orders записей: ${orders.length}`)
|
||||
orders.forEach((order, i) => {
|
||||
console.log(` ${i+1}. ${order.supplier.name} - статус: ${order.status} (${order.items.length} позиций)`)
|
||||
})
|
||||
|
||||
// 4. Проверяем что V1 Supply НЕ создаются для FULFILLMENT_CONSUMABLES
|
||||
console.log('\n🚫 ПРОВЕРКА ОТСУТСТВИЯ V1 ЗАПИСЕЙ...')
|
||||
const v1Supplies = await prisma.supply.findMany({
|
||||
where: {
|
||||
organizationId: fulfillmentOrg.id,
|
||||
type: 'FULFILLMENT_CONSUMABLES'
|
||||
}
|
||||
})
|
||||
|
||||
console.log(`📊 V1 Supply записей с типом FULFILLMENT_CONSUMABLES: ${v1Supplies.length}`)
|
||||
if (v1Supplies.length === 0) {
|
||||
console.log('✅ V1 система корректно отключена!')
|
||||
} else {
|
||||
console.log('⚠️ Найдены V1 записи - возможна проблема!')
|
||||
v1Supplies.forEach((supply, i) => {
|
||||
console.log(` ${i+1}. ${supply.name} - ${supply.createdAt}`)
|
||||
})
|
||||
}
|
||||
|
||||
// 5. Проверяем старые SupplyOrder записи
|
||||
console.log('\n📦 ПРОВЕРКА СТАРЫХ SUPPLYORDER...')
|
||||
const oldSupplyOrders = await prisma.supplyOrder.findMany({
|
||||
where: {
|
||||
organizationId: fulfillmentOrg.id,
|
||||
consumableType: 'FULFILLMENT_CONSUMABLES'
|
||||
}
|
||||
})
|
||||
|
||||
console.log(`📊 Старых SupplyOrder с FULFILLMENT_CONSUMABLES: ${oldSupplyOrders.length}`)
|
||||
|
||||
console.log('\n🎯 РЕЗУЛЬТАТ ТЕСТИРОВАНИЯ:')
|
||||
console.log(` V2 Inventory: ${inventory.length} записей ✅`)
|
||||
console.log(` V2 Orders: ${orders.length} записей ✅`)
|
||||
console.log(` V1 Supplies: ${v1Supplies.length} записей ${v1Supplies.length === 0 ? '✅' : '⚠️'}`)
|
||||
console.log(` Старые SupplyOrder: ${oldSupplyOrders.length} записей`)
|
||||
|
||||
if (inventory.length > 0 && v1Supplies.length === 0) {
|
||||
console.log('\n🎉 V2 СИСТЕМА ФУЛФИЛМЕНТА РАБОТАЕТ КОРРЕКТНО!')
|
||||
} else {
|
||||
console.log('\n⚠️ Обнаружены проблемы в V2 системе')
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ ОШИБКА при тестировании:', error)
|
||||
} finally {
|
||||
await prisma.$disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
testV2Migration()
|
Reference in New Issue
Block a user