| | | 1 | | #region Usings |
| | | 2 | | using Respawn.Graph; |
| | | 3 | | #endregion |
| | | 4 | | |
| | | 5 | | namespace ZhEaIsNsAaBn.IntegrationTestingBases; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// The tables of ZhEaIsNsAaBn.DbSeeder (plain names; this package doesn't reference DbSeeder). Keep them — and the seed |
| | | 9 | | /// of the reset, so seed data applied once (e.g. by <c>Migrate()</c> with <c>UseDbSeeder</c>) survives every <c>ResetDa |
| | | 10 | | /// </summary> |
| | | 11 | | /// <example> |
| | | 12 | | /// <code> |
| | | 13 | | /// protected override Table[] TablesToIgnore => DbSeederTables.WithSeedTables( "Countries", "PaymentMethods" ); |
| | | 14 | | /// </code> |
| | | 15 | | /// </example> |
| | | 16 | | public static class DbSeederTables |
| | | 17 | | { |
| | | 18 | | /// <summary>The seed history table: which seed migrations are applied.</summary> |
| | | 19 | | public const string History = "__SeedMigrationsHistory"; |
| | | 20 | | |
| | | 21 | | /// <summary>The append-only seed audit table.</summary> |
| | | 22 | | public const string Audit = "__SeedMigrationsAudit"; |
| | | 23 | | |
| | | 24 | | |
| | | 25 | | /// <summary>Both DbSeeder tables.</summary> |
| | 7 | 26 | | public static IReadOnlyList<string> All { get; } = [ History, Audit ]; |
| | | 27 | | |
| | | 28 | | |
| | | 29 | | /// <summary>The DbSeeder tables plus the seeded tables, as Respawn tables for <c>TablesToIgnore</c>.</summary> |
| | | 30 | | /// <param name="seedTables">The tables that hold seed data (default schema), e.g. <c>"Countries"</c>.</param> |
| | | 31 | | /// <returns>The tables to keep.</returns> |
| | | 32 | | /// <exception cref="ArgumentNullException"><paramref name="seedTables"/> is <see langword="null"/>.</exception> |
| | | 33 | | public static Table[] WithSeedTables( params string[] seedTables ) |
| | | 34 | | { |
| | 10 | 35 | | ArgumentNullException.ThrowIfNull( seedTables ); |
| | | 36 | | |
| | 7 | 37 | | return [ ..All.Concat( seedTables ).Select( t => new Table( t ) ) ]; |
| | | 38 | | } |
| | | 39 | | } |