2022-02-16 19:09:06 +02:00
|
|
|
|
using System.Linq;
|
2023-01-12 01:01:36 +02:00
|
|
|
|
using e = Netmash.Infrastructure.DatabaseMigration.Entities;
|
|
|
|
|
using m = Netmash.Infrastructure.DatabaseMigration.Models;
|
2022-02-16 19:09:06 +02:00
|
|
|
|
|
2023-01-12 01:01:36 +02:00
|
|
|
|
namespace Netmash.Infrastructure.DatabaseMigration.Extensions
|
2022-02-16 19:09:06 +02:00
|
|
|
|
{
|
|
|
|
|
internal static class Mappings
|
|
|
|
|
{
|
|
|
|
|
public static m.MigratedVersion ToModel(this e.MigratedVersion migratedVersion)
|
|
|
|
|
{
|
|
|
|
|
return new m.MigratedVersion()
|
|
|
|
|
{
|
|
|
|
|
Version = migratedVersion.Version,
|
|
|
|
|
Scripts = migratedVersion.Scripts.Select(z => z.Script).ToArray()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static m.MigrationSignature ToModel(this e.MigrationSignature migrationSignature)
|
|
|
|
|
{
|
|
|
|
|
return new m.MigrationSignature()
|
|
|
|
|
{
|
|
|
|
|
MigrationDate = migrationSignature.MigrationDate,
|
|
|
|
|
MachineName = migrationSignature.MachineName,
|
|
|
|
|
LastVersion = migrationSignature.LastVersion,
|
|
|
|
|
MigratedVersions = migrationSignature.MigratedVersions.Select(z => z.ToModel()).ToArray()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static e.MigratedVersion ToEntity(this m.MigratedVersion migratedVersion)
|
|
|
|
|
{
|
|
|
|
|
return new e.MigratedVersion()
|
|
|
|
|
{
|
|
|
|
|
Version = migratedVersion.Version,
|
|
|
|
|
Scripts = migratedVersion.Scripts.Select(z => new e.MigratedScript() { Script = z }).ToArray()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static e.MigrationSignature ToEntity(this m.MigrationSignature migrationSignature)
|
|
|
|
|
{
|
|
|
|
|
return new e.MigrationSignature()
|
|
|
|
|
{
|
|
|
|
|
MigrationDate = migrationSignature.MigrationDate,
|
|
|
|
|
MachineName = migrationSignature.MachineName,
|
|
|
|
|
LastVersion = migrationSignature.LastVersion,
|
|
|
|
|
MigratedVersions = migrationSignature.MigratedVersions.Select(z => z.ToEntity()).ToArray()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|