SHA256
GuestDocument Versions - Part 1:
- Changed GuestDocument PK from `DocumentType`+`DocumentNumber` to to `ID`+`Version` for future versioning. - Added DB field "IsLastVersion" to simplify queries where only last/current version is allowed. - Updated GuestDocument DB fields type for `CreateTime` & `UpdateTime` to add precision. - Updated usages of GuestDocument PK to new PK. - Limit delete of a GuestDocument when it's currently used in a StayEntry. Note: DB changes require recreating db tables, so all data is lost and migration "rollback" is not allowed.
This commit is contained in:
1 parent
a01eed82e1
commit
887c3d787a
21 files changed
+525
-93
No files matched your search
@@ -19,6 +19,9 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
@@ -28,34 +31,45 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("GuestDocumentsDocumentType")
|
||||
.HasColumnType("character varying(8)");
|
||||
b.Property<long>("GuestDocumentsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("GuestDocumentsDocumentNum")
|
||||
.HasColumnType("character varying(64)");
|
||||
b.Property<int>("GuestDocumentsVersion")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
|
||||
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.HasIndex("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
|
||||
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<string>("DocumentType")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("Version")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("DocumentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
@@ -65,6 +79,9 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<bool>("IsLastVersion")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
@@ -96,7 +113,7 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
@@ -126,7 +143,7 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("DocumentType", "DocumentNum");
|
||||
b.HasKey("Id", "Version");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
@@ -178,7 +195,7 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum")
|
||||
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user