Skip to content

Commit ac5ae19

Browse files
author
CIS Guru
committed
feat: unsupported schema UI, quarantine rename, robust import with column aliases
1 parent 26b97c8 commit ac5ae19

File tree

46 files changed

+6023
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+6023
-227
lines changed

0-Nine.Core/Entities/Property.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public class Property : BaseModel
9696
public string Description { get; set; } = string.Empty;
9797

9898
[JsonInclude]
99-
[Display(Name = "Is Available?", Description = "Indicates if the property is currently available for lease")]
100-
public bool IsAvailable { get; set; } = true;
99+
[Display(Name = "Is Active?", Description = "Indicates if the property is active in the system")]
100+
public bool IsActive { get; set; } = true;
101101

102102
[JsonInclude]
103103
[StringLength(50)]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
namespace Nine.Core.Exceptions;
2+
3+
/// <summary>
4+
/// Groups database-specific exceptions thrown by the Nine database layer.
5+
/// </summary>
6+
public static class DatabaseExceptions
7+
{
8+
/// <summary>
9+
/// Thrown when the database schema is more than two major versions behind the
10+
/// current release and cannot be bridged automatically. The database has been
11+
/// copied to <see cref="SchemaNotSupportedException.BackupPath"/> before this
12+
/// exception is thrown; the user must import their data via the application's
13+
/// import workflow instead.
14+
/// </summary>
15+
public class SchemaNotSupportedException : Exception
16+
{
17+
/// <summary>Full path of the backup copy made before this exception was thrown.</summary>
18+
public string BackupPath { get; }
19+
20+
public SchemaNotSupportedException(string backupPath)
21+
: base(
22+
"The database has an incompatible schema version and cannot be upgraded " +
23+
$"automatically. A backup has been saved to: {backupPath}")
24+
{
25+
BackupPath = backupPath;
26+
}
27+
}
28+
29+
/// <summary>
30+
/// Thrown when the database schema structure is invalid, unrecognised, or
31+
/// internally inconsistent in a way that prevents normal operation.
32+
/// </summary>
33+
public class SchemaInvalidException : Exception
34+
{
35+
public SchemaInvalidException(string message) : base(message) { }
36+
37+
public SchemaInvalidException(string message, Exception inner)
38+
: base(message, inner) { }
39+
}
40+
41+
/// <summary>
42+
/// Thrown when an era bridge migration step fails. Used inside
43+
/// <c>ApplyFirstAncestorBridgeAsync</c> and <c>ApplySecondAncestorBridgeAsync</c>
44+
/// to surface a descriptive failure without leaking raw SQL exception details to
45+
/// the UI layer.
46+
/// </summary>
47+
public class MigrationException : Exception
48+
{
49+
public MigrationException(string message) : base(message) { }
50+
51+
public MigrationException(string message, Exception inner)
52+
: base(message, inner) { }
53+
}
54+
}

1-Nine.Infrastructure/Data/CompiledModels/PropertyEntityType.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ public static RuntimeEntityType Create(RuntimeModel model, RuntimeEntityType bas
8787
fieldInfo: typeof(Property).GetField("<Description>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
8888
maxLength: 1000);
8989

90-
var isAvailable = runtimeEntityType.AddProperty(
91-
"IsAvailable",
90+
var isActive = runtimeEntityType.AddProperty(
91+
"IsActive",
9292
typeof(bool),
93-
propertyInfo: typeof(Property).GetProperty("IsAvailable", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
94-
fieldInfo: typeof(Property).GetField("<IsAvailable>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
93+
propertyInfo: typeof(Property).GetProperty("IsActive", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
94+
fieldInfo: typeof(Property).GetField("<IsActive>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
9595
sentinel: false);
9696

9797
var isDeleted = runtimeEntityType.AddProperty(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.EntityFrameworkCore;
2+
using Microsoft.EntityFrameworkCore.Design;
3+
4+
namespace Nine.Infrastructure.Data;
5+
6+
/// <summary>
7+
/// Design-time factory to allow dotnet-ef migrations to run without the full application host.
8+
/// </summary>
9+
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
10+
{
11+
public ApplicationDbContext CreateDbContext(string[] args)
12+
{
13+
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
14+
optionsBuilder.UseSqlite("DataSource=design-time-temp.db");
15+
return new ApplicationDbContext(optionsBuilder.Options);
16+
}
17+
}

0 commit comments

Comments
 (0)