From 842502e82c4ddfea05a5f77c361aaa27f75afc42 Mon Sep 17 00:00:00 2001 From: ivar Date: Sun, 26 Oct 2025 22:57:28 +0100 Subject: Refactor db schema and add audits --- api/WhatApi/Migrations/DatabaseModelSnapshot.cs | 129 +++++++++++++++++++++++- 1 file changed, 125 insertions(+), 4 deletions(-) (limited to 'api/WhatApi/Migrations/DatabaseModelSnapshot.cs') diff --git a/api/WhatApi/Migrations/DatabaseModelSnapshot.cs b/api/WhatApi/Migrations/DatabaseModelSnapshot.cs index f1e5fcb..1d81e04 100644 --- a/api/WhatApi/Migrations/DatabaseModelSnapshot.cs +++ b/api/WhatApi/Migrations/DatabaseModelSnapshot.cs @@ -1,5 +1,6 @@ // using System; +using System.Collections.Generic; using System.Net; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -25,6 +26,50 @@ namespace WhatApi.Migrations NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis"); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("WhatApi.Tables.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.PrimitiveCollection>("ChangedColumns") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("DateUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("EntityName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property>("NewValues") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property>("OldValues") + .IsRequired() + .HasColumnType("jsonb"); + + b.Property("PrimaryKey") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("TrailType") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("EntityName"); + + b.ToTable("audit_trails", (string)null); + }); + modelBuilder.Entity("WhatApi.Tables.Content", b => { b.Property("Id") @@ -34,20 +79,30 @@ namespace WhatApi.Migrations b.Property("BlobId") .HasColumnType("uuid"); - b.Property("Created") + b.Property("CreatedAtUtc") .HasColumnType("timestamp with time zone"); + b.Property("CreatedBy") + .HasColumnType("uuid"); + b.Property("Ip") .IsRequired() .HasColumnType("inet"); b.Property("Mime") .IsRequired() - .HasColumnType("text"); + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); b.HasKey("Id"); - b.ToTable("Content"); + b.ToTable("content", (string)null); }); modelBuilder.Entity("WhatApi.Tables.Place", b => @@ -59,10 +114,25 @@ namespace WhatApi.Migrations b.Property("ContentId") .HasColumnType("uuid"); + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + b.Property("Location") .IsRequired() .HasColumnType("geometry(point,4326)"); + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("uuid"); + b.HasKey("Id"); b.HasIndex("ContentId"); @@ -71,7 +141,49 @@ namespace WhatApi.Migrations NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Location"), "gist"); - b.ToTable("Place", (string)null); + b.HasIndex("UserId"); + + b.ToTable("place", (string)null); + }); + + modelBuilder.Entity("WhatApi.Tables.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("LastSeen") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpdatedAtUtc") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedBy") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.ToTable("user", (string)null); }); modelBuilder.Entity("WhatApi.Tables.Place", b => @@ -82,8 +194,17 @@ namespace WhatApi.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("WhatApi.Tables.User", null) + .WithMany("Places") + .HasForeignKey("UserId"); + b.Navigation("Content"); }); + + modelBuilder.Entity("WhatApi.Tables.User", b => + { + b.Navigation("Places"); + }); #pragma warning restore 612, 618 } } -- cgit v1.3