summaryrefslogtreecommitdiffstats
path: root/api/WhatApi/Migrations
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-03 21:49:20 +0100
committerivar <i@oiee.no>2025-12-03 21:49:20 +0100
commitcd70f54266d708867a1eb35870bc755bc5b2df32 (patch)
treef0a8ec571ef3f345ac74293b4cb11918878b3ed5 /api/WhatApi/Migrations
parent5bd9ad8bd1740dcff179d66718532086304ca4c4 (diff)
downloadwhat-cd70f54266d708867a1eb35870bc755bc5b2df32.tar.xz
what-cd70f54266d708867a1eb35870bc755bc5b2df32.zip
Refactor db
Diffstat (limited to 'api/WhatApi/Migrations')
-rw-r--r--api/WhatApi/Migrations/20251026215643_Initial.Designer.cs214
-rw-r--r--api/WhatApi/Migrations/20251202203059_PasswordMaxLength.cs36
-rw-r--r--api/WhatApi/Migrations/20251203204812_Initial.Designer.cs (renamed from api/WhatApi/Migrations/20251202203059_PasswordMaxLength.Designer.cs)26
-rw-r--r--api/WhatApi/Migrations/20251203204812_Initial.cs (renamed from api/WhatApi/Migrations/20251026215643_Initial.cs)8
-rw-r--r--api/WhatApi/Migrations/AppDatabaseModelSnapshot.cs (renamed from api/WhatApi/Migrations/DatabaseModelSnapshot.cs)24
5 files changed, 29 insertions, 279 deletions
diff --git a/api/WhatApi/Migrations/20251026215643_Initial.Designer.cs b/api/WhatApi/Migrations/20251026215643_Initial.Designer.cs
deleted file mode 100644
index c430ed1..0000000
--- a/api/WhatApi/Migrations/20251026215643_Initial.Designer.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-// <auto-generated />
-using System;
-using System.Collections.Generic;
-using System.Net;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using NetTopologySuite.Geometries;
-using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-using WhatApi;
-
-#nullable disable
-
-namespace WhatApi.Migrations
-{
- [DbContext(typeof(Database))]
- [Migration("20251026215643_Initial")]
- partial class Initial
- {
- /// <inheritdoc />
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "9.0.9")
- .HasAnnotation("Relational:MaxIdentifierLength", 63);
-
- NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis");
- NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
-
- modelBuilder.Entity("WhatApi.Tables.AuditTrail", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.PrimitiveCollection<List<string>>("ChangedColumns")
- .IsRequired()
- .HasColumnType("jsonb");
-
- b.Property<DateTimeOffset>("DateUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<string>("EntityName")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property<Dictionary<string, object>>("NewValues")
- .IsRequired()
- .HasColumnType("jsonb");
-
- b.Property<Dictionary<string, object>>("OldValues")
- .IsRequired()
- .HasColumnType("jsonb");
-
- b.Property<string>("PrimaryKey")
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property<string>("TrailType")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("EntityName");
-
- b.ToTable("audit_trails", (string)null);
- });
-
- modelBuilder.Entity("WhatApi.Tables.Content", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<Guid>("BlobId")
- .HasColumnType("uuid");
-
- b.Property<DateTimeOffset>("CreatedAtUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<Guid>("CreatedBy")
- .HasColumnType("uuid");
-
- b.Property<IPAddress>("Ip")
- .IsRequired()
- .HasColumnType("inet");
-
- b.Property<string>("Mime")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property<DateTimeOffset?>("UpdatedAtUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<Guid?>("UpdatedBy")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.ToTable("content", (string)null);
- });
-
- modelBuilder.Entity("WhatApi.Tables.Place", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<Guid>("ContentId")
- .HasColumnType("uuid");
-
- b.Property<DateTimeOffset>("CreatedAtUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<Guid>("CreatedBy")
- .HasColumnType("uuid");
-
- b.Property<Point>("Location")
- .IsRequired()
- .HasColumnType("geometry(point,4326)");
-
- b.Property<DateTimeOffset?>("UpdatedAtUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<Guid?>("UpdatedBy")
- .HasColumnType("uuid");
-
- b.Property<Guid?>("UserId")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.HasIndex("ContentId");
-
- b.HasIndex("Location");
-
- NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Location"), "gist");
-
- b.HasIndex("UserId");
-
- b.ToTable("place", (string)null);
- });
-
- modelBuilder.Entity("WhatApi.Tables.User", b =>
- {
- b.Property<Guid>("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid");
-
- b.Property<DateTimeOffset>("CreatedAtUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<Guid>("CreatedBy")
- .HasColumnType("uuid");
-
- b.Property<string>("Email")
- .IsRequired()
- .HasMaxLength(100)
- .HasColumnType("character varying(100)");
-
- b.Property<DateTimeOffset?>("LastSeen")
- .HasColumnType("timestamp with time zone");
-
- b.Property<string>("Name")
- .IsRequired()
- .HasMaxLength(50)
- .HasColumnType("character varying(50)");
-
- b.Property<string>("Password")
- .IsRequired()
- .HasColumnType("text");
-
- b.Property<DateTimeOffset?>("UpdatedAtUtc")
- .HasColumnType("timestamp with time zone");
-
- b.Property<Guid?>("UpdatedBy")
- .HasColumnType("uuid");
-
- b.HasKey("Id");
-
- b.ToTable("user", (string)null);
- });
-
- modelBuilder.Entity("WhatApi.Tables.Place", b =>
- {
- b.HasOne("WhatApi.Tables.Content", "Content")
- .WithMany()
- .HasForeignKey("ContentId")
- .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
- }
- }
-}
diff --git a/api/WhatApi/Migrations/20251202203059_PasswordMaxLength.cs b/api/WhatApi/Migrations/20251202203059_PasswordMaxLength.cs
deleted file mode 100644
index 8129df8..0000000
--- a/api/WhatApi/Migrations/20251202203059_PasswordMaxLength.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace WhatApi.Migrations
-{
- /// <inheritdoc />
- public partial class PasswordMaxLength : Migration
- {
- /// <inheritdoc />
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn<string>(
- name: "Password",
- table: "user",
- type: "character varying(100)",
- maxLength: 100,
- nullable: false,
- oldClrType: typeof(string),
- oldType: "text");
- }
-
- /// <inheritdoc />
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.AlterColumn<string>(
- name: "Password",
- table: "user",
- type: "text",
- nullable: false,
- oldClrType: typeof(string),
- oldType: "character varying(100)",
- oldMaxLength: 100);
- }
- }
-}
diff --git a/api/WhatApi/Migrations/20251202203059_PasswordMaxLength.Designer.cs b/api/WhatApi/Migrations/20251203204812_Initial.Designer.cs
index f23a067..39847ba 100644
--- a/api/WhatApi/Migrations/20251202203059_PasswordMaxLength.Designer.cs
+++ b/api/WhatApi/Migrations/20251203204812_Initial.Designer.cs
@@ -8,15 +8,15 @@ using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NetTopologySuite.Geometries;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-using WhatApi;
+using WhatApi.Database;
#nullable disable
namespace WhatApi.Migrations
{
- [DbContext(typeof(Database))]
- [Migration("20251202203059_PasswordMaxLength")]
- partial class PasswordMaxLength
+ [DbContext(typeof(AppDatabase))]
+ [Migration("20251203204812_Initial")]
+ partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -29,7 +29,7 @@ namespace WhatApi.Migrations
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis");
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
- modelBuilder.Entity("WhatApi.Tables.AuditTrail", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.AuditTrail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -73,7 +73,7 @@ namespace WhatApi.Migrations
b.ToTable("audit_trails", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.Content", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.Content", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -108,7 +108,7 @@ namespace WhatApi.Migrations
b.ToTable("content", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.Place", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.Place", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -149,7 +149,7 @@ namespace WhatApi.Migrations
b.ToTable("place", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.User", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -174,7 +174,7 @@ namespace WhatApi.Migrations
.HasMaxLength(50)
.HasColumnType("character varying(50)");
- b.Property<string>("Password")
+ b.Property<string>("PasswordHash")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
@@ -190,22 +190,22 @@ namespace WhatApi.Migrations
b.ToTable("user", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.Place", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.Place", b =>
{
- b.HasOne("WhatApi.Tables.Content", "Content")
+ b.HasOne("WhatApi.Database.Tables.Content", "Content")
.WithMany()
.HasForeignKey("ContentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.HasOne("WhatApi.Tables.User", null)
+ b.HasOne("WhatApi.Database.Tables.User", null)
.WithMany("Places")
.HasForeignKey("UserId");
b.Navigation("Content");
});
- modelBuilder.Entity("WhatApi.Tables.User", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.User", b =>
{
b.Navigation("Places");
});
diff --git a/api/WhatApi/Migrations/20251026215643_Initial.cs b/api/WhatApi/Migrations/20251203204812_Initial.cs
index b8f0444..f49a9f3 100644
--- a/api/WhatApi/Migrations/20251026215643_Initial.cs
+++ b/api/WhatApi/Migrations/20251203204812_Initial.cs
@@ -29,7 +29,7 @@ namespace WhatApi.Migrations
DateUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
OldValues = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: false),
NewValues = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: false),
- ChangedColumns = table.Column<List<string>>(type: "jsonb", nullable: false)
+ ChangedColumns = table.Column<string>(type: "jsonb", nullable: false)
},
constraints: table =>
{
@@ -61,7 +61,7 @@ namespace WhatApi.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Email = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
- Password = table.Column<string>(type: "text", nullable: false),
+ PasswordHash = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
LastSeen = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
@@ -80,11 +80,11 @@ namespace WhatApi.Migrations
Id = table.Column<Guid>(type: "uuid", nullable: false),
ContentId = table.Column<Guid>(type: "uuid", nullable: false),
Location = table.Column<Point>(type: "geometry(point,4326)", nullable: false),
+ UserId = table.Column<Guid>(type: "uuid", nullable: true),
CreatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAtUtc = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
CreatedBy = table.Column<Guid>(type: "uuid", nullable: false),
- UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true),
- UserId = table.Column<Guid>(type: "uuid", nullable: true)
+ UpdatedBy = table.Column<Guid>(type: "uuid", nullable: true)
},
constraints: table =>
{
diff --git a/api/WhatApi/Migrations/DatabaseModelSnapshot.cs b/api/WhatApi/Migrations/AppDatabaseModelSnapshot.cs
index babdf01..24973b0 100644
--- a/api/WhatApi/Migrations/DatabaseModelSnapshot.cs
+++ b/api/WhatApi/Migrations/AppDatabaseModelSnapshot.cs
@@ -7,14 +7,14 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using NetTopologySuite.Geometries;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
-using WhatApi;
+using WhatApi.Database;
#nullable disable
namespace WhatApi.Migrations
{
- [DbContext(typeof(Database))]
- partial class DatabaseModelSnapshot : ModelSnapshot
+ [DbContext(typeof(AppDatabase))]
+ partial class AppDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
@@ -26,7 +26,7 @@ namespace WhatApi.Migrations
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "postgis");
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
- modelBuilder.Entity("WhatApi.Tables.AuditTrail", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.AuditTrail", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -70,7 +70,7 @@ namespace WhatApi.Migrations
b.ToTable("audit_trails", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.Content", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.Content", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -105,7 +105,7 @@ namespace WhatApi.Migrations
b.ToTable("content", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.Place", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.Place", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -146,7 +146,7 @@ namespace WhatApi.Migrations
b.ToTable("place", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.User", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.User", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
@@ -171,7 +171,7 @@ namespace WhatApi.Migrations
.HasMaxLength(50)
.HasColumnType("character varying(50)");
- b.Property<string>("Password")
+ b.Property<string>("PasswordHash")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
@@ -187,22 +187,22 @@ namespace WhatApi.Migrations
b.ToTable("user", (string)null);
});
- modelBuilder.Entity("WhatApi.Tables.Place", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.Place", b =>
{
- b.HasOne("WhatApi.Tables.Content", "Content")
+ b.HasOne("WhatApi.Database.Tables.Content", "Content")
.WithMany()
.HasForeignKey("ContentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.HasOne("WhatApi.Tables.User", null)
+ b.HasOne("WhatApi.Database.Tables.User", null)
.WithMany("Places")
.HasForeignKey("UserId");
b.Navigation("Content");
});
- modelBuilder.Entity("WhatApi.Tables.User", b =>
+ modelBuilder.Entity("WhatApi.Database.Tables.User", b =>
{
b.Navigation("Places");
});