Files
adam-acs/database/mongo_migrations/001_create_devices_collection.ts
Kevin L'Hereec f9e56c78b1 refactor: migrate all internal imports to package.json subpath aliases
- Add #domain, #protocol, #utils aliases to package.json imports map
- Replace all relative imports (./, ../, ../..) in app/ and
  database/mongo_migrations/ with the corresponding #alias imports,
  eliminating relative path traversal across the codebase
- Remove dead code: ConfigurationVersionModel.findByConfigurationIdentifier
  (unused, superseded by paginateVersions) and unused exception classes
  (NotFoundException, UnprocessableEntityException, DatabaseException)
  from app/exceptions/index.ts, keeping only BadRequestException
- Fix pre-existing syntax error in configuration_version.ts (mismatched
  parenthesis) that broke tsc
- Fix eqeqeq violation in configuration_service.ts and isNaN ->
  Number.isNaN in configuration_engine.ts / cwmp-1-0.ts / exchange_controller.ts
- Fix no-shadow violation in cwmp-1-0.ts EventStruct constructor
- Prettier formatting pass on touched files

Validated: tsc --noEmit clean, eslint app/ clean, full test suite green.
2026-07-22 11:45:14 +02:00

28 lines
1019 B
TypeScript

import { MongoMigration } from '#database/mongo_migrator'
export default class CreateDevicesCollection extends MongoMigration {
async up(): Promise<void> {
const collection = this.db.collection('devices')
await collection.createIndex(
{
'deviceId.manufacturer': 1,
'deviceId.oui': 1,
'deviceId.productClass': 1,
'deviceId.serialNumber': 1,
},
{ unique: true, name: 'idx_deviceId_compound' }
)
await collection.createIndex({ identifier: 1 }, { unique: true, name: 'idx_identifier' })
await collection.createIndex({ 'deviceId.manufacturer': 1 }, { name: 'idx_manufacturer' })
await collection.createIndex({ 'deviceId.oui': 1 }, { name: 'idx_oui' })
await collection.createIndex({ 'deviceId.productClass': 1 }, { name: 'idx_productClass' })
await collection.createIndex({ 'deviceId.serialNumber': 1 }, { name: 'idx_serialNumber' })
}
async down(): Promise<void> {
await this.db.dropCollection('devices').catch(() => {})
}
}