Path: redb/redb.Tests.Integration/Models/MigrationProbeModels.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Models/MigrationProbeModels.cs ---- using redb.Core.Attributes; using redb.Core.Pro.Migration; namespace redb.Tests.Integration.Models; /// /// Props for the Pro data-migration suite: TotalPrice is recomputed from Quantity * Price. /// [RedbScheme("Миграции: пробный объект", Name = "migration_probe")] public class MigrationProbeProps { public long Quantity { get; set; } public double Price { get; set; } public double TotalPrice { get; set; } } /// /// The migration under test — the canonical ComputedFrom case from the Pro docs. /// public class MigrationProbeMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.TotalPrice) .ComputedFrom(p => p.Quantity * p.Price); } } /// /// Props for the DefaultValue and Transform migrations: one string field each, so the two /// migrations of the suite never touch each other's rows. /// [RedbScheme("Migrations: default value and transform probe", Name = "migration_edit_probe")] public class MigrationEditProbeProps { public string? Status { get; set; } public string? Phone { get; set; } public bool Enabled { get; set; } public DateTime? Due { get; set; } public DateTimeOffset? Seen { get; set; } } /// DefaultValue of a DateTime and a DateTimeOffset: the literal must be what the engine stores. public class MigrationDateDefaultValueMigration : IRedbMigration { public static readonly DateTime DueDefault = new(2026, 5, 17, 10, 30, 15, DateTimeKind.Utc); public static readonly DateTimeOffset SeenDefault = new(2026, 5, 17, 13, 30, 15, TimeSpan.FromHours(3)); public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Due).DefaultValue(DueDefault); builder.Property(p => p.Seen).DefaultValue(SeenDefault); } } /// DefaultValue: fills the stored rows of Status that hold no value. public class MigrationDefaultValueMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Status).DefaultValue("Active"); } } /// DefaultValue of a bool: the literal is the engine's own (SQL Server has no TRUE). public class MigrationBoolDefaultValueMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Enabled).DefaultValue(true); } } /// Transform: rewrites Phone in place. public class MigrationTransformMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.Phone).Transform(v => v.Replace("-", "")); } } /// /// Props for ComputedFrom on a [RedbUnique] target: the migration rewrites the value, so the stored key /// of the old value must not stay behind. /// [RedbScheme("Migrations: computed unique key probe", Name = "migration_unique_probe")] public class MigrationUniqueProbeProps { public long Quantity { get; set; } public double Price { get; set; } [RedbUnique] public double TotalPrice { get; set; } } /// ComputedFrom onto the key field. public class MigrationUniqueProbeMigration : IRedbMigration { public void Configure(IMigrationBuilder builder) { builder.Property(p => p.TotalPrice) .ComputedFrom(p => p.Quantity * p.Price); } }