rama creada apartir de master en j
This commit is contained in:
@@ -5,6 +5,12 @@ using MongoMigrations.Core;
|
||||
namespace adas_core.Infrastructure.Migrations.MongoMigrations;
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// Represents a database migration (version 0.1.0) responsible for updating the patient data schema.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inherits from the <see cref="Migration"/> base class, indicating it is intended to be applied as part of an Entity Framework (or similar) migration pipeline to evolve the underlying data store.
|
||||
/// </remarks>
|
||||
public class U_0_1_0_UpdateDataPatien : Migration
|
||||
{
|
||||
public U_0_1_0_UpdateDataPatien() : base(10)
|
||||
|
||||
+53
-41
@@ -4,6 +4,12 @@ using MongoMigrations.Core;
|
||||
|
||||
namespace adas_core.Infrastructure.Migrations.MongoMigrations;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a database migration responsible for updating the display configuration related to a driver in version 0.1.1.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inherits from <see cref="Migration"/> to support schema or data changes associated with the 0.1.1 release.
|
||||
/// </remarks>
|
||||
public class U_0_1_1_UpdateDisplayConfigDriver : Migration
|
||||
{
|
||||
public U_0_1_1_UpdateDisplayConfigDriver() : base(11)
|
||||
@@ -12,55 +18,61 @@ public class U_0_1_1_UpdateDisplayConfigDriver : Migration
|
||||
"Genera el campo Type en todos los documentos de la coleccion DisplayConfig por que el nuevo driver no expone _t para polimorfia";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates documents in the <c>config_displays</c> collection by mapping the <c>_t</c> discriminator field
|
||||
/// to a new <c>type</c> field, normalizing values to <c>DisplayNurse</c>, <c>StandarDisplay</c>, or <c>SmartDisplay</c>
|
||||
/// (defaulting to <c>Unknown</c> for any other value), removing the original <c>_t</c> field, and merging the
|
||||
/// results back into the same collection while discarding documents that do not already have a match.
|
||||
/// </summary>
|
||||
public override void Update()
|
||||
{
|
||||
var collection = Database.GetCollection<BsonDocument>("config_displays");
|
||||
|
||||
var pipeline = new[]
|
||||
{
|
||||
new BsonDocument("$set", new BsonDocument
|
||||
var collection = Database.GetCollection<BsonDocument>("config_displays");
|
||||
|
||||
var pipeline = new[]
|
||||
{
|
||||
new BsonDocument("$set", new BsonDocument
|
||||
{
|
||||
"type", new BsonDocument("$switch", new BsonDocument
|
||||
{
|
||||
"type", new BsonDocument("$switch", new BsonDocument
|
||||
{
|
||||
"branches", new BsonArray
|
||||
{
|
||||
new BsonDocument
|
||||
"branches", new BsonArray
|
||||
{
|
||||
{ "case", new BsonDocument("$eq", new BsonArray { "$_t", "DisplayNurse" }) },
|
||||
{ "then", "DisplayNurse" }
|
||||
},
|
||||
new BsonDocument
|
||||
{
|
||||
{ "case", new BsonDocument("$eq", new BsonArray { "$_t", "StandarDisplay" }) },
|
||||
{ "then", "StandarDisplay" }
|
||||
},
|
||||
new BsonDocument
|
||||
{
|
||||
{ "case", new BsonDocument("$eq", new BsonArray { "$_t", "SmartDisplay" }) },
|
||||
{ "then", "SmartDisplay" }
|
||||
new BsonDocument
|
||||
{
|
||||
{ "case", new BsonDocument("$eq", new BsonArray { "$_t", "DisplayNurse" }) },
|
||||
{ "then", "DisplayNurse" }
|
||||
},
|
||||
new BsonDocument
|
||||
{
|
||||
{ "case", new BsonDocument("$eq", new BsonArray { "$_t", "StandarDisplay" }) },
|
||||
{ "then", "StandarDisplay" }
|
||||
},
|
||||
new BsonDocument
|
||||
{
|
||||
{ "case", new BsonDocument("$eq", new BsonArray { "$_t", "SmartDisplay" }) },
|
||||
{ "then", "SmartDisplay" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{ "default", "Unknown" }
|
||||
})
|
||||
}
|
||||
}),
|
||||
|
||||
new BsonDocument("$unset", "_t"),
|
||||
|
||||
new BsonDocument("$merge", new BsonDocument
|
||||
{
|
||||
{ "into", "config_displays" },
|
||||
{ "whenMatched", "merge" },
|
||||
{ "whenNotMatched", "discard" }
|
||||
})
|
||||
};
|
||||
|
||||
collection.AggregateToCollection<BsonDocument>(pipeline);
|
||||
// collection.AggregateToCollection<BsonDocument>(pipeline, "config_displays");
|
||||
|
||||
}
|
||||
},
|
||||
{ "default", "Unknown" }
|
||||
})
|
||||
}
|
||||
}),
|
||||
|
||||
new BsonDocument("$unset", "_t"),
|
||||
|
||||
new BsonDocument("$merge", new BsonDocument
|
||||
{
|
||||
{ "into", "config_displays" },
|
||||
{ "whenMatched", "merge" },
|
||||
{ "whenNotMatched", "discard" }
|
||||
})
|
||||
};
|
||||
|
||||
collection.AggregateToCollection<BsonDocument>(pipeline);
|
||||
// collection.AggregateToCollection<BsonDocument>(pipeline, "config_displays");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+48
-39
@@ -4,6 +4,12 @@ using MongoMigrations.Core;
|
||||
|
||||
namespace adas_core.Infrastructure.Migrations.MongoMigrations;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a database migration responsible for updating the Point of Care configuration schema.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The migration identifier prefix (U_0_1_2) indicates a specific ordering or version step within the migration sequence.
|
||||
/// </remarks>
|
||||
public class U_0_1_2_UpdatePointOfCareConfig : Migration
|
||||
{
|
||||
public U_0_1_2_UpdatePointOfCareConfig() : base(12)
|
||||
@@ -12,48 +18,51 @@ public class U_0_1_2_UpdatePointOfCareConfig : Migration
|
||||
"Borra los elementos de configuracion de poc, relay, camera y beacon y deja el place holder del nuevo modelo";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates all point-of-care documents in the database by migrating their embedded configuration arrays (beacons, cameras, and relayList) to empty identifier list structures (beaconIdList, cameraIdList, and relayIdList), preserving the existing arrays' data not retained in this operation.
|
||||
/// </summary>
|
||||
public override void Update()
|
||||
{
|
||||
var collection = Database.GetCollection<BsonDocument>("pointOfCares");
|
||||
|
||||
var filter = Builders<BsonDocument>.Filter.Exists("configuration");
|
||||
var documents = collection.Find(filter).ToList();
|
||||
|
||||
foreach (var doc in documents)
|
||||
{
|
||||
var configuration = doc["configuration"].AsBsonDocument;
|
||||
|
||||
// Listas nuevas de IDs
|
||||
var beaconIdList = new BsonArray();
|
||||
var cameraIdList = new BsonArray();
|
||||
var relayIdList = new BsonArray();
|
||||
|
||||
// 1. Procesar Beacons (si existen)
|
||||
if (configuration.Contains("beacons") && configuration["beacons"].IsBsonArray)
|
||||
var collection = Database.GetCollection<BsonDocument>("pointOfCares");
|
||||
|
||||
var filter = Builders<BsonDocument>.Filter.Exists("configuration");
|
||||
var documents = collection.Find(filter).ToList();
|
||||
|
||||
foreach (var doc in documents)
|
||||
{
|
||||
configuration.Remove("beacons");
|
||||
var configuration = doc["configuration"].AsBsonDocument;
|
||||
|
||||
// Listas nuevas de IDs
|
||||
var beaconIdList = new BsonArray();
|
||||
var cameraIdList = new BsonArray();
|
||||
var relayIdList = new BsonArray();
|
||||
|
||||
// 1. Procesar Beacons (si existen)
|
||||
if (configuration.Contains("beacons") && configuration["beacons"].IsBsonArray)
|
||||
{
|
||||
configuration.Remove("beacons");
|
||||
}
|
||||
|
||||
configuration["beaconIdList"] = beaconIdList;
|
||||
|
||||
// 2. Procesar Cameras (si existen)
|
||||
if (configuration.Contains("cameras") && configuration["cameras"].IsBsonArray)
|
||||
{
|
||||
configuration.Remove("cameras");
|
||||
}
|
||||
|
||||
configuration["cameraIdList"] = cameraIdList;
|
||||
|
||||
// 3. Procesar RelayList (si existen)
|
||||
if (configuration.Contains("relayList") && configuration["relayList"].IsBsonArray)
|
||||
{
|
||||
configuration.Remove("relayList");
|
||||
}
|
||||
|
||||
configuration["relayIdList"] = relayIdList;
|
||||
|
||||
// Actualizar el documento en la base de datos
|
||||
collection.ReplaceOne(Builders<BsonDocument>.Filter.Eq("_id", doc["_id"]), doc);
|
||||
}
|
||||
|
||||
configuration["beaconIdList"] = beaconIdList;
|
||||
|
||||
// 2. Procesar Cameras (si existen)
|
||||
if (configuration.Contains("cameras") && configuration["cameras"].IsBsonArray)
|
||||
{
|
||||
configuration.Remove("cameras");
|
||||
}
|
||||
|
||||
configuration["cameraIdList"] = cameraIdList;
|
||||
|
||||
// 3. Procesar RelayList (si existen)
|
||||
if (configuration.Contains("relayList") && configuration["relayList"].IsBsonArray)
|
||||
{
|
||||
configuration.Remove("relayList");
|
||||
}
|
||||
|
||||
configuration["relayIdList"] = relayIdList;
|
||||
|
||||
// Actualizar el documento en la base de datos
|
||||
collection.ReplaceOne(Builders<BsonDocument>.Filter.Eq("_id", doc["_id"]), doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ using MongoMigrations.Core;
|
||||
|
||||
namespace adas_core.Infrastructure.Migrations.MongoMigrations;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a database migration that updates the LanguageBarrier component to version 0.1.3.
|
||||
/// </summary>
|
||||
public class U_0_1_3_UpdateLanguageBarrier : Migration
|
||||
{
|
||||
public U_0_1_3_UpdateLanguageBarrier() : base(13)
|
||||
|
||||
Reference in New Issue
Block a user