Some checks failed
Build / Build Backend (push) Has been cancelled
Build / Build Mobile (TypeScript Check) (push) Has been cancelled
Lint / Lint Backend (push) Has been cancelled
Lint / Lint Mobile (push) Has been cancelled
Test / Backend E2E Tests (push) Has been cancelled
Test / Mobile Unit Tests (push) Has been cancelled
Build / Build Docker Image (push) Has been cancelled
- Add exports module with PDF/CSV/Excel generation - Add reports module for inventory analytics - Add POS integrations module - Add database migrations for exports, movements and integrations - Add GitHub Actions CI/CD workflow with Docker support - Add mobile export and reports screens with tests - Update epic documentation with traceability - Add deployment and security guides Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
568 lines
25 KiB
YAML
568 lines
25 KiB
YAML
# MiInventario - Database Inventory
|
|
# Version: 3.0.0
|
|
# Actualizado: 2026-01-13
|
|
|
|
metadata:
|
|
proyecto: miinventario
|
|
componente: database
|
|
motor: PostgreSQL
|
|
version_motor: "15"
|
|
orm: TypeORM
|
|
version: "3.0.0"
|
|
estado: completado
|
|
creado: 2026-01-10
|
|
actualizado: 2026-01-13
|
|
actualizado_por: "Agente Arquitecto de Documentación"
|
|
|
|
# ===========================================
|
|
# CONEXION
|
|
# ===========================================
|
|
conexion:
|
|
host: localhost
|
|
puerto: 5433
|
|
nombre: miinventario_dev
|
|
usuario: postgres
|
|
ssl: false
|
|
|
|
# ===========================================
|
|
# RESUMEN
|
|
# ===========================================
|
|
resumen:
|
|
schemas_implementados: 1
|
|
tablas_implementadas: 21
|
|
enums_implementados: 14
|
|
indices_implementados: 17
|
|
foreign_keys_implementados: 13
|
|
migraciones_ejecutadas: 3
|
|
rls_habilitado: false
|
|
nota: "El proyecto usa TypeORM con schema 'public' en lugar de schemas separados"
|
|
|
|
# ===========================================
|
|
# TABLAS IMPLEMENTADAS
|
|
# ===========================================
|
|
tablas:
|
|
- nombre: users
|
|
descripcion: "Usuarios del sistema"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: phone, tipo: varchar(20), unique: true, nullable: true }
|
|
- { nombre: email, tipo: varchar(255), unique: true, nullable: true }
|
|
- { nombre: passwordHash, tipo: varchar(255), nullable: true }
|
|
- { nombre: name, tipo: varchar(100), nullable: true }
|
|
- { nombre: businessName, tipo: varchar(100), nullable: true }
|
|
- { nombre: location, tipo: varchar(255), nullable: true }
|
|
- { nombre: giro, tipo: varchar(50), nullable: true }
|
|
- { nombre: role, tipo: "users_role_enum", default: "USER" }
|
|
- { nombre: isActive, tipo: boolean, default: true }
|
|
- { nombre: fcmToken, tipo: varchar(255), nullable: true }
|
|
- { nombre: stripeCustomerId, tipo: varchar(100), nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
|
|
- nombre: stores
|
|
descripcion: "Tiendas de usuarios"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: ownerId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: name, tipo: varchar(100), required: true }
|
|
- { nombre: giro, tipo: varchar(50), nullable: true }
|
|
- { nombre: address, tipo: varchar(255), nullable: true }
|
|
- { nombre: phone, tipo: varchar(20), nullable: true }
|
|
- { nombre: logoUrl, tipo: varchar(500), nullable: true }
|
|
- { nombre: settings, tipo: jsonb, default: "{}" }
|
|
- { nombre: isActive, tipo: boolean, default: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
|
|
- nombre: store_users
|
|
descripcion: "Relacion usuarios-tiendas"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: store_id, tipo: uuid, fk: "stores.id" }
|
|
- { nombre: user_id, tipo: uuid, fk: "users.id" }
|
|
- { nombre: role, tipo: "store_users_role_enum" }
|
|
- { nombre: isActive, tipo: boolean, default: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
|
|
- nombre: videos
|
|
descripcion: "Videos subidos para procesamiento"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: storeId, tipo: uuid, fk: "stores.id" }
|
|
- { nombre: uploadedById, tipo: uuid, fk: "users.id" }
|
|
- { nombre: fileName, tipo: varchar(255), required: true }
|
|
- { nombre: s3Key, tipo: varchar(500), nullable: true }
|
|
- { nombre: fileSize, tipo: bigint, nullable: true }
|
|
- { nombre: durationSeconds, tipo: integer, nullable: true }
|
|
- { nombre: status, tipo: "videos_status_enum", default: "PENDING" }
|
|
- { nombre: processingProgress, tipo: integer, default: 0 }
|
|
- { nombre: itemsDetected, tipo: integer, default: 0 }
|
|
- { nombre: creditsUsed, tipo: integer, default: 0 }
|
|
- { nombre: errorMessage, tipo: text, nullable: true }
|
|
- { nombre: metadata, tipo: jsonb, nullable: true }
|
|
- { nombre: processedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
|
|
- nombre: inventory_items
|
|
descripcion: "Items de inventario detectados"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: storeId, tipo: uuid, fk: "stores.id" }
|
|
- { nombre: detectedByVideoId, tipo: uuid, fk: "videos.id", nullable: true }
|
|
- { nombre: name, tipo: varchar(255), required: true }
|
|
- { nombre: category, tipo: varchar(100), nullable: true }
|
|
- { nombre: subcategory, tipo: varchar(100), nullable: true }
|
|
- { nombre: barcode, tipo: varchar(50), nullable: true }
|
|
- { nombre: quantity, tipo: integer, default: 0 }
|
|
- { nombre: minStock, tipo: integer, nullable: true }
|
|
- { nombre: price, tipo: "decimal(10,2)", nullable: true }
|
|
- { nombre: cost, tipo: "decimal(10,2)", nullable: true }
|
|
- { nombre: imageUrl, tipo: varchar(500), nullable: true }
|
|
- { nombre: detectionConfidence, tipo: "decimal(5,2)", nullable: true }
|
|
- { nombre: isManuallyEdited, tipo: boolean, default: false }
|
|
- { nombre: metadata, tipo: jsonb, nullable: true }
|
|
- { nombre: lastCountedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [storeId, name] }
|
|
- { columnas: [storeId, category] }
|
|
- { columnas: [storeId, barcode] }
|
|
|
|
- nombre: credit_balances
|
|
descripcion: "Saldos de creditos por usuario"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id", unique: true }
|
|
- { nombre: balance, tipo: integer, default: 0 }
|
|
- { nombre: totalPurchased, tipo: integer, default: 0 }
|
|
- { nombre: totalConsumed, tipo: integer, default: 0 }
|
|
- { nombre: totalFromReferrals, tipo: integer, default: 0 }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
|
|
- nombre: credit_packages
|
|
descripcion: "Paquetes de creditos disponibles"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: name, tipo: varchar(100), required: true }
|
|
- { nombre: description, tipo: varchar(255), nullable: true }
|
|
- { nombre: credits, tipo: integer, required: true }
|
|
- { nombre: priceMXN, tipo: "decimal(10,2)", required: true }
|
|
- { nombre: isPopular, tipo: boolean, default: false }
|
|
- { nombre: isActive, tipo: boolean, default: true }
|
|
- { nombre: sortOrder, tipo: integer, default: 0 }
|
|
- { nombre: stripePriceId, tipo: varchar(100), nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
|
|
- nombre: credit_transactions
|
|
descripcion: "Transacciones de creditos"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: type, tipo: "credit_transactions_type_enum" }
|
|
- { nombre: amount, tipo: integer, required: true }
|
|
- { nombre: balanceAfter, tipo: integer, required: true }
|
|
- { nombre: description, tipo: varchar(255), nullable: true }
|
|
- { nombre: referenceId, tipo: uuid, nullable: true }
|
|
- { nombre: referenceType, tipo: varchar(50), nullable: true }
|
|
- { nombre: metadata, tipo: jsonb, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [userId, createdAt] }
|
|
- { columnas: [type, createdAt] }
|
|
|
|
- nombre: payments
|
|
descripcion: "Pagos de usuarios"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: packageId, tipo: uuid, fk: "credit_packages.id", nullable: true }
|
|
- { nombre: amountMXN, tipo: "decimal(10,2)", required: true }
|
|
- { nombre: creditsGranted, tipo: integer, required: true }
|
|
- { nombre: method, tipo: "payments_method_enum" }
|
|
- { nombre: status, tipo: "payments_status_enum", default: "PENDING" }
|
|
- { nombre: externalId, tipo: varchar(255), nullable: true }
|
|
- { nombre: provider, tipo: varchar(50), nullable: true }
|
|
- { nombre: voucherUrl, tipo: varchar(500), nullable: true }
|
|
- { nombre: voucherCode, tipo: varchar(100), nullable: true }
|
|
- { nombre: expiresAt, tipo: timestamp, nullable: true }
|
|
- { nombre: completedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: errorMessage, tipo: text, nullable: true }
|
|
- { nombre: metadata, tipo: jsonb, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [userId, createdAt] }
|
|
- { columnas: [status, createdAt] }
|
|
- { columnas: [externalId] }
|
|
|
|
- nombre: referrals
|
|
descripcion: "Sistema de referidos"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: referrerId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: referredId, tipo: uuid, fk: "users.id", nullable: true }
|
|
- { nombre: referralCode, tipo: varchar(20), unique: true }
|
|
- { nombre: status, tipo: "referrals_status_enum", default: "PENDING" }
|
|
- { nombre: referrerBonusCredits, tipo: integer, default: 0 }
|
|
- { nombre: referredBonusCredits, tipo: integer, default: 0 }
|
|
- { nombre: registeredAt, tipo: timestamp, nullable: true }
|
|
- { nombre: qualifiedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: rewardedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: fraudHold, tipo: boolean, default: false, descripcion: "Indica si el referido esta en espera por sospecha de fraude" }
|
|
- { nombre: fraudReason, tipo: varchar(255), nullable: true, descripcion: "Razon de la sospecha de fraude" }
|
|
- { nombre: reviewedBy, tipo: uuid, fk: "users.id", nullable: true, descripcion: "Admin que reviso el caso de fraude" }
|
|
- { nombre: reviewedAt, tipo: timestamp, nullable: true, descripcion: "Fecha de revision del caso" }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [referrerId] }
|
|
- { columnas: [referredId] }
|
|
- { columnas: [referralCode] }
|
|
|
|
- nombre: notifications
|
|
descripcion: "Notificaciones de usuarios"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: type, tipo: "notifications_type_enum" }
|
|
- { nombre: title, tipo: varchar(255), required: true }
|
|
- { nombre: body, tipo: text, nullable: true }
|
|
- { nombre: isRead, tipo: boolean, default: false }
|
|
- { nombre: isPushSent, tipo: boolean, default: false }
|
|
- { nombre: data, tipo: jsonb, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [userId, isRead] }
|
|
- { columnas: [userId, createdAt] }
|
|
|
|
- nombre: otps
|
|
descripcion: "Codigos OTP para verificacion"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: phone, tipo: varchar(20), required: true }
|
|
- { nombre: code, tipo: varchar(6), required: true }
|
|
- { nombre: purpose, tipo: "otps_purpose_enum" }
|
|
- { nombre: attempts, tipo: integer, default: 0 }
|
|
- { nombre: isUsed, tipo: boolean, default: false }
|
|
- { nombre: expiresAt, tipo: timestamp, required: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [phone, purpose] }
|
|
- { columnas: [expiresAt] }
|
|
|
|
- nombre: refresh_tokens
|
|
descripcion: "Tokens de refresco JWT"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: token, tipo: varchar(500), required: true }
|
|
- { nombre: deviceInfo, tipo: varchar(100), nullable: true }
|
|
- { nombre: ipAddress, tipo: varchar(50), nullable: true }
|
|
- { nombre: isRevoked, tipo: boolean, default: false }
|
|
- { nombre: expiresAt, tipo: timestamp, required: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [userId] }
|
|
- { columnas: [token] }
|
|
- { columnas: [expiresAt] }
|
|
|
|
- nombre: audit_logs
|
|
descripcion: "Registros de auditoria del sistema"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id", nullable: true }
|
|
- { nombre: action, tipo: varchar(100), required: true }
|
|
- { nombre: entity, tipo: varchar(100), required: true }
|
|
- { nombre: entityId, tipo: uuid, nullable: true }
|
|
- { nombre: oldValues, tipo: jsonb, nullable: true }
|
|
- { nombre: newValues, tipo: jsonb, nullable: true }
|
|
- { nombre: ipAddress, tipo: varchar(50), nullable: true }
|
|
- { nombre: userAgent, tipo: varchar(255), nullable: true }
|
|
- { nombre: metadata, tipo: jsonb, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [userId, createdAt] }
|
|
- { columnas: [entity, entityId] }
|
|
- { columnas: [action, createdAt] }
|
|
|
|
- nombre: promotions
|
|
descripcion: "Promociones y codigos de descuento"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: code, tipo: varchar(50), unique: true, required: true }
|
|
- { nombre: name, tipo: varchar(100), required: true }
|
|
- { nombre: description, tipo: varchar(255), nullable: true }
|
|
- { nombre: type, tipo: "promotions_type_enum", required: true }
|
|
- { nombre: value, tipo: "decimal(10,2)", required: true }
|
|
- { nombre: minPurchase, tipo: "decimal(10,2)", nullable: true }
|
|
- { nombre: maxUses, tipo: integer, nullable: true }
|
|
- { nombre: usedCount, tipo: integer, default: 0 }
|
|
- { nombre: startsAt, tipo: timestamp, nullable: true }
|
|
- { nombre: expiresAt, tipo: timestamp, nullable: true }
|
|
- { nombre: isActive, tipo: boolean, default: true }
|
|
- { nombre: createdBy, tipo: uuid, fk: "users.id" }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [code] }
|
|
- { columnas: [isActive, expiresAt] }
|
|
|
|
- nombre: ia_providers
|
|
descripcion: "Configuracion de proveedores de IA"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: name, tipo: varchar(100), required: true }
|
|
- { nombre: slug, tipo: varchar(50), unique: true, required: true }
|
|
- { nombre: apiEndpoint, tipo: varchar(500), required: true }
|
|
- { nombre: apiKeyEncrypted, tipo: varchar(500), nullable: true }
|
|
- { nombre: modelName, tipo: varchar(100), nullable: true }
|
|
- { nombre: costPerRequest, tipo: "decimal(10,4)", nullable: true }
|
|
- { nombre: maxRequestsPerMinute, tipo: integer, nullable: true }
|
|
- { nombre: isActive, tipo: boolean, default: true }
|
|
- { nombre: priority, tipo: integer, default: 0 }
|
|
- { nombre: settings, tipo: jsonb, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [slug] }
|
|
- { columnas: [isActive, priority] }
|
|
|
|
- nombre: corrections
|
|
descripcion: "Correcciones de usuario a detecciones de IA"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: itemId, tipo: uuid, fk: "inventory_items.id" }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: type, tipo: "corrections_type_enum", required: true }
|
|
- { nombre: originalValue, tipo: jsonb, required: true }
|
|
- { nombre: correctedValue, tipo: jsonb, required: true }
|
|
- { nombre: reason, tipo: varchar(255), nullable: true }
|
|
- { nombre: isApplied, tipo: boolean, default: false }
|
|
- { nombre: appliedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [itemId] }
|
|
- { columnas: [userId, createdAt] }
|
|
- { columnas: [type, isApplied] }
|
|
|
|
- nombre: ground_truth
|
|
descripcion: "Datos verificados para entrenamiento de IA"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: itemId, tipo: uuid, fk: "inventory_items.id", nullable: true }
|
|
- { nombre: videoId, tipo: uuid, fk: "videos.id", nullable: true }
|
|
- { nombre: imageUrl, tipo: varchar(500), nullable: true }
|
|
- { nombre: productName, tipo: varchar(255), required: true }
|
|
- { nombre: category, tipo: varchar(100), nullable: true }
|
|
- { nombre: subcategory, tipo: varchar(100), nullable: true }
|
|
- { nombre: barcode, tipo: varchar(50), nullable: true }
|
|
- { nombre: boundingBox, tipo: jsonb, nullable: true }
|
|
- { nombre: verifiedBy, tipo: uuid, fk: "users.id" }
|
|
- { nombre: status, tipo: "ground_truth_status_enum", default: "PENDING" }
|
|
- { nombre: metadata, tipo: jsonb, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [status] }
|
|
- { columnas: [category, subcategory] }
|
|
- { columnas: [verifiedBy] }
|
|
|
|
- nombre: product_submissions
|
|
descripcion: "Productos enviados por usuarios para catalogar"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: userId, tipo: uuid, fk: "users.id" }
|
|
- { nombre: storeId, tipo: uuid, fk: "stores.id", nullable: true }
|
|
- { nombre: productName, tipo: varchar(255), required: true }
|
|
- { nombre: barcode, tipo: varchar(50), nullable: true }
|
|
- { nombre: category, tipo: varchar(100), nullable: true }
|
|
- { nombre: imageUrl, tipo: varchar(500), nullable: true }
|
|
- { nombre: description, tipo: text, nullable: true }
|
|
- { nombre: status, tipo: "product_submissions_status_enum", default: "PENDING" }
|
|
- { nombre: reviewedBy, tipo: uuid, fk: "users.id", nullable: true }
|
|
- { nombre: reviewNotes, tipo: text, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
- { nombre: updatedAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [userId] }
|
|
- { columnas: [status] }
|
|
- { columnas: [barcode] }
|
|
|
|
- nombre: validation_requests
|
|
descripcion: "Solicitudes de validacion de detecciones"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: videoId, tipo: uuid, fk: "videos.id" }
|
|
- { nombre: itemId, tipo: uuid, fk: "inventory_items.id", nullable: true }
|
|
- { nombre: requestType, tipo: varchar(50), required: true }
|
|
- { nombre: payload, tipo: jsonb, required: true }
|
|
- { nombre: priority, tipo: integer, default: 0 }
|
|
- { nombre: status, tipo: varchar(20), default: "PENDING" }
|
|
- { nombre: processedAt, tipo: timestamp, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [videoId] }
|
|
- { columnas: [status, priority] }
|
|
- { columnas: [requestType] }
|
|
|
|
- nombre: validation_responses
|
|
descripcion: "Respuestas a solicitudes de validacion"
|
|
estado: implementado
|
|
campos:
|
|
- { nombre: id, tipo: uuid, pk: true, default: uuid_generate_v4() }
|
|
- { nombre: requestId, tipo: uuid, fk: "validation_requests.id" }
|
|
- { nombre: providerId, tipo: uuid, fk: "ia_providers.id", nullable: true }
|
|
- { nombre: response, tipo: jsonb, required: true }
|
|
- { nombre: confidence, tipo: "decimal(5,2)", nullable: true }
|
|
- { nombre: processingTimeMs, tipo: integer, nullable: true }
|
|
- { nombre: costIncurred, tipo: "decimal(10,4)", nullable: true }
|
|
- { nombre: isSuccess, tipo: boolean, default: true }
|
|
- { nombre: errorMessage, tipo: text, nullable: true }
|
|
- { nombre: createdAt, tipo: timestamp, default: now() }
|
|
indices:
|
|
- { columnas: [requestId] }
|
|
- { columnas: [providerId] }
|
|
- { columnas: [isSuccess, createdAt] }
|
|
|
|
# ===========================================
|
|
# ENUMS
|
|
# ===========================================
|
|
enums:
|
|
- nombre: users_role_enum
|
|
valores: [USER, VIEWER, MODERATOR, ADMIN, SUPER_ADMIN]
|
|
|
|
- nombre: videos_status_enum
|
|
valores: [PENDING, UPLOADING, UPLOADED, PROCESSING, COMPLETED, FAILED]
|
|
|
|
- nombre: store_users_role_enum
|
|
valores: [OWNER, OPERATOR]
|
|
|
|
- nombre: referrals_status_enum
|
|
valores: [PENDING, REGISTERED, QUALIFIED, REWARDED]
|
|
|
|
- nombre: payments_method_enum
|
|
valores: [CARD, OXXO, 7ELEVEN]
|
|
|
|
- nombre: payments_status_enum
|
|
valores: [PENDING, PROCESSING, COMPLETED, FAILED, REFUNDED, EXPIRED]
|
|
|
|
- nombre: notifications_type_enum
|
|
valores: [VIDEO_PROCESSING_COMPLETE, VIDEO_PROCESSING_FAILED, LOW_CREDITS, PAYMENT_COMPLETE, PAYMENT_FAILED, REFERRAL_BONUS, PROMO, SYSTEM]
|
|
|
|
- nombre: credit_transactions_type_enum
|
|
valores: [PURCHASE, CONSUMPTION, REFERRAL_BONUS, PROMO, REFUND]
|
|
|
|
- nombre: otps_purpose_enum
|
|
valores: [REGISTRATION, LOGIN, PASSWORD_RESET]
|
|
|
|
- nombre: corrections_type_enum
|
|
valores: [NAME, CATEGORY, QUANTITY, PRICE, BARCODE, IMAGE, OTHER]
|
|
|
|
- nombre: ground_truth_status_enum
|
|
valores: [PENDING, VERIFIED, REJECTED, NEEDS_REVIEW]
|
|
|
|
- nombre: product_submissions_status_enum
|
|
valores: [PENDING, APPROVED, REJECTED, NEEDS_INFO]
|
|
|
|
- nombre: promotions_type_enum
|
|
valores: [PERCENTAGE, FIXED_AMOUNT, CREDITS_BONUS, FREE_CREDITS]
|
|
|
|
# ===========================================
|
|
# MIGRACIONES
|
|
# ===========================================
|
|
migraciones:
|
|
ultima_migracion: "1736600000000-CreateAdminTables"
|
|
total_ejecutadas: 3
|
|
historial:
|
|
- nombre: Init1768099560565
|
|
fecha: 2026-01-10
|
|
descripcion: "Creacion inicial de todas las tablas"
|
|
archivo: "src/migrations/1768099560565-Init.ts"
|
|
tablas_creadas: 13
|
|
enums_creados: 10
|
|
indices_creados: 17
|
|
foreign_keys: 13
|
|
|
|
- nombre: CreateFeedbackTables1736502000000
|
|
fecha: 2026-01-10
|
|
descripcion: "Tablas para sistema de feedback y correcciones de IA"
|
|
archivo: "src/migrations/1736502000000-CreateFeedbackTables.ts"
|
|
tablas_creadas: 4
|
|
enums_creados: 2
|
|
nota: "Incluye corrections, ground_truth, validation_requests, validation_responses"
|
|
|
|
- nombre: CreateAdminTables1736600000000
|
|
fecha: 2026-01-13
|
|
descripcion: "Tablas para administracion, auditoria y promociones"
|
|
archivo: "src/migrations/1736600000000-CreateAdminTables.ts"
|
|
tablas_creadas: 4
|
|
enums_creados: 2
|
|
nota: "Incluye audit_logs, promotions, ia_providers, product_submissions"
|
|
|
|
# ===========================================
|
|
# SEEDS
|
|
# ===========================================
|
|
seeds:
|
|
- archivo: "src/database/seed.ts"
|
|
descripcion: "Seed para paquetes de creditos"
|
|
estado: implementado
|
|
datos:
|
|
- credit_packages (4 paquetes: Basico, Popular, Premium, Empresarial)
|
|
|
|
# ===========================================
|
|
# CHANGELOG
|
|
# ===========================================
|
|
changelog:
|
|
- version: "1.0.0"
|
|
fecha: 2026-01-10
|
|
cambios:
|
|
- "Creacion inicial del inventario de base de datos"
|
|
- "Definicion de 9 schemas planificados"
|
|
- "Definicion de 30 tablas planificadas"
|
|
|
|
- version: "2.0.0"
|
|
fecha: 2026-01-10
|
|
cambios:
|
|
- "Actualizacion completa con estado real implementado"
|
|
- "13 tablas implementadas con TypeORM"
|
|
- "10 ENUMs creados"
|
|
- "17 indices configurados"
|
|
- "13 foreign keys establecidos"
|
|
- "Migracion Init ejecutada exitosamente"
|
|
- "Cambio de arquitectura: schema unico (public) vs multiples"
|
|
|
|
- version: "3.0.0"
|
|
fecha: 2026-01-13
|
|
cambios:
|
|
- "Agregadas 8 nuevas tablas: audit_logs, promotions, ia_providers, corrections, ground_truth, product_submissions, validation_requests, validation_responses"
|
|
- "Agregados 4 nuevos ENUMs: corrections_type_enum, ground_truth_status_enum, product_submissions_status_enum, promotions_type_enum"
|
|
- "Actualizado users_role_enum con roles: VIEWER, MODERATOR, SUPER_ADMIN"
|
|
- "Documentados campos de fraude en referrals: fraudHold, fraudReason, reviewedBy, reviewedAt"
|
|
- "Agregadas 2 nuevas migraciones: CreateFeedbackTables, CreateAdminTables"
|
|
- "Total tablas: 21, Total ENUMs: 14"
|
|
- "Estado actualizado a completado"
|