diff --git a/src/BUTR.CrashReportServer/Contexts/Config/IdEntityConfiguration.cs b/src/BUTR.CrashReportServer/Contexts/Config/IdEntityConfiguration.cs index 19b6211..69e5a26 100644 --- a/src/BUTR.CrashReportServer/Contexts/Config/IdEntityConfiguration.cs +++ b/src/BUTR.CrashReportServer/Contexts/Config/IdEntityConfiguration.cs @@ -9,7 +9,7 @@ public class IdEntityConfiguration : BaseEntityConfiguration { protected override void ConfigureModel(EntityTypeBuilder builder) { - builder.Property(x => x.FileId).HasColumnName("file_id").HasDefaultValueSql("hex(randomblob(3))"); + builder.Property(x => x.FileId).HasColumnName("file_id"); builder.Property(x => x.CrashReportId).HasColumnName("crash_report_id"); builder.Property(x => x.Version).HasColumnName("version"); builder.Property(x => x.Created).HasColumnName("created"); diff --git a/src/BUTR.CrashReportServer/Contexts/OldAppDbContext.cs b/src/BUTR.CrashReportServer/Contexts/OldAppDbContext.cs index f6e2a72..0ebd4b9 100644 --- a/src/BUTR.CrashReportServer/Contexts/OldAppDbContext.cs +++ b/src/BUTR.CrashReportServer/Contexts/OldAppDbContext.cs @@ -6,7 +6,7 @@ namespace BUTR.CrashReportServer.Contexts; -public class FileEntityConfiguration : BaseEntityConfiguration +public class OldFileEntityConfiguration : BaseEntityConfiguration { protected override void ConfigureModel(EntityTypeBuilder builder) { @@ -23,7 +23,7 @@ protected override void ConfigureModel(EntityTypeBuilder builder) builder.Navigation(x => x.Id).AutoInclude(); } } -public class IdEntityConfiguration : BaseEntityConfiguration +public class OldIdEntityConfiguration : BaseEntityConfiguration { protected override void ConfigureModel(EntityTypeBuilder builder) { @@ -62,8 +62,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); - modelBuilder.ApplyConfiguration(new IdEntityConfiguration()); - modelBuilder.ApplyConfiguration(new FileEntityConfiguration()); + modelBuilder.ApplyConfiguration(new OldIdEntityConfiguration()); + modelBuilder.ApplyConfiguration(new OldFileEntityConfiguration()); modelBuilder.ApplyConfiguration(new OldJsonEntityConfiguration()); } } \ No newline at end of file diff --git a/src/BUTR.CrashReportServer/Migrations/20230401192915_Initial.Designer.cs b/src/BUTR.CrashReportServer/Migrations/20230401192915_Initial.Designer.cs deleted file mode 100644 index d6cced9..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230401192915_Initial.Designer.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -using System; -using BUTR.CrashReportServer.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20230401192915_Initial")] - partial class Initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.Property("Name") - .HasColumnType("TEXT") - .HasColumnName("name"); - - b.Property("Created") - .HasColumnType("TEXT") - .HasColumnName("created"); - - b.Property("DataCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.Property("Modified") - .HasColumnType("TEXT") - .HasColumnName("modified"); - - b.Property("SizeOriginal") - .HasColumnType("INTEGER") - .HasColumnName("size_original"); - - b.HasKey("Name") - .HasName("file_entity_pkey"); - - b.ToTable("file_entity", (string)null); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/BUTR.CrashReportServer/Migrations/20230401192915_Initial.cs b/src/BUTR.CrashReportServer/Migrations/20230401192915_Initial.cs deleted file mode 100644 index 1b8d815..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230401192915_Initial.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -using System; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - /// - public partial class Initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "file_entity", - columns: table => new - { - name = table.Column(type: "TEXT", nullable: false), - created = table.Column(type: "TEXT", nullable: false), - modified = table.Column(type: "TEXT", nullable: false), - size_original = table.Column(type: "INTEGER", nullable: false), - data_compressed = table.Column(type: "BLOB", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("file_entity_pkey", x => x.name); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "file_entity"); - } - } -} \ No newline at end of file diff --git a/src/BUTR.CrashReportServer/Migrations/20230927114922_Json.Designer.cs b/src/BUTR.CrashReportServer/Migrations/20230927114922_Json.Designer.cs deleted file mode 100644 index 614183e..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230927114922_Json.Designer.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -using System; -using BUTR.CrashReportServer.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20230927114922_Json")] - partial class Json - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("name"); - - b.Property("DataCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.HasKey("FileId") - .HasName("file_entity_pkey"); - - b.ToTable("file_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.IdEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("CrashReportId") - .HasColumnType("TEXT") - .HasColumnName("crash_report_id"); - - b.Property("Created") - .HasColumnType("TEXT") - .HasColumnName("created"); - - b.HasKey("FileId"); - - b.HasIndex("CrashReportId"); - - b.ToTable("id_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("CrashReportCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.HasKey("FileId"); - - b.ToTable("json_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.HasOne("BUTR.CrashReportServer.Models.Database.IdEntity", "Id") - .WithOne() - .HasForeignKey("BUTR.CrashReportServer.Models.Database.FileEntity", "FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Id"); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => - { - b.HasOne("BUTR.CrashReportServer.Models.Database.IdEntity", "Id") - .WithOne() - .HasForeignKey("BUTR.CrashReportServer.Models.Database.JsonEntity", "FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/BUTR.CrashReportServer/Migrations/20230927114922_Json.cs b/src/BUTR.CrashReportServer/Migrations/20230927114922_Json.cs deleted file mode 100644 index 755f1c5..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230927114922_Json.cs +++ /dev/null @@ -1,118 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -using System; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - /// - public partial class Json : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "id_entity", - columns: table => new - { - file_id = table.Column(type: "TEXT", nullable: false), - crash_report_id = table.Column(type: "TEXT", nullable: false), - created = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_id_entity", x => x.file_id); - }); - - migrationBuilder.CreateTable( - name: "json_entity", - columns: table => new - { - file_id = table.Column(type: "TEXT", nullable: false), - data_compressed = table.Column(type: "BLOB", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_json_entity", x => x.file_id); - table.ForeignKey( - name: "FK_json_entity_id_entity_file_id", - column: x => x.file_id, - principalTable: "id_entity", - principalColumn: "file_id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.Sql(""" - UPDATE file_entity - SET name = REPLACE(name, '.html', ''); - """); - - migrationBuilder.Sql(""" - INSERT INTO id_entity(file_id, created, crash_report_id) - SELECT name, created, '00000000-0000-0000-0000-000000000000' - FROM file_entity; - """); - - migrationBuilder.CreateIndex( - name: "IX_id_entity_crash_report_id", - table: "id_entity", - column: "crash_report_id"); - - migrationBuilder.AddForeignKey( - name: "FK_file_entity_id_entity_name", - table: "file_entity", - column: "name", - principalTable: "id_entity", - principalColumn: "file_id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.DropColumn( - name: "created", - table: "file_entity"); - - migrationBuilder.DropColumn( - name: "modified", - table: "file_entity"); - - migrationBuilder.DropColumn( - name: "size_original", - table: "file_entity"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_file_entity_id_entity_name", - table: "file_entity"); - - migrationBuilder.DropTable( - name: "json_entity"); - - migrationBuilder.DropTable( - name: "id_entity"); - - migrationBuilder.AddColumn( - name: "created", - table: "file_entity", - type: "TEXT", - nullable: false, - defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); - - migrationBuilder.AddColumn( - name: "modified", - table: "file_entity", - type: "TEXT", - nullable: false, - defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); - - migrationBuilder.AddColumn( - name: "size_original", - table: "file_entity", - type: "INTEGER", - nullable: false, - defaultValue: 0L); - } - } -} \ No newline at end of file diff --git a/src/BUTR.CrashReportServer/Migrations/20230929075117_FileEntity.Designer.cs b/src/BUTR.CrashReportServer/Migrations/20230929075117_FileEntity.Designer.cs deleted file mode 100644 index fa9f888..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230929075117_FileEntity.Designer.cs +++ /dev/null @@ -1,101 +0,0 @@ -// -using System; -using BUTR.CrashReportServer.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20230929075117_FileEntity")] - partial class FileEntity - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("DataCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.HasKey("FileId") - .HasName("file_entity_pkey"); - - b.ToTable("file_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.IdEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("CrashReportId") - .HasColumnType("TEXT") - .HasColumnName("crash_report_id"); - - b.Property("Created") - .HasColumnType("TEXT") - .HasColumnName("created"); - - b.HasKey("FileId"); - - b.HasIndex("CrashReportId"); - - b.ToTable("id_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("CrashReportCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.HasKey("FileId"); - - b.ToTable("json_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.HasOne("BUTR.CrashReportServer.Models.Database.IdEntity", "Id") - .WithOne() - .HasForeignKey("BUTR.CrashReportServer.Models.Database.FileEntity", "FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Id"); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => - { - b.HasOne("BUTR.CrashReportServer.Models.Database.IdEntity", "Id") - .WithOne() - .HasForeignKey("BUTR.CrashReportServer.Models.Database.JsonEntity", "FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/BUTR.CrashReportServer/Migrations/20230929075117_FileEntity.cs b/src/BUTR.CrashReportServer/Migrations/20230929075117_FileEntity.cs deleted file mode 100644 index a2d5b74..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230929075117_FileEntity.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - /// - public partial class FileEntity : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_file_entity_id_entity_name", - table: "file_entity"); - - migrationBuilder.RenameColumn( - name: "name", - table: "file_entity", - newName: "file_id"); - - migrationBuilder.AddForeignKey( - name: "FK_file_entity_id_entity_file_id", - table: "file_entity", - column: "file_id", - principalTable: "id_entity", - principalColumn: "file_id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_file_entity_id_entity_file_id", - table: "file_entity"); - - migrationBuilder.RenameColumn( - name: "file_id", - table: "file_entity", - newName: "name"); - - migrationBuilder.AddForeignKey( - name: "FK_file_entity_id_entity_name", - table: "file_entity", - column: "name", - principalTable: "id_entity", - principalColumn: "file_id", - onDelete: ReferentialAction.Cascade); - } - } -} \ No newline at end of file diff --git a/src/BUTR.CrashReportServer/Migrations/20230929122557_IdEntityGenerator.Designer.cs b/src/BUTR.CrashReportServer/Migrations/20230929122557_IdEntityGenerator.Designer.cs deleted file mode 100644 index 26a3905..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230929122557_IdEntityGenerator.Designer.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -using System; -using BUTR.CrashReportServer.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - [DbContext(typeof(AppDbContext))] - [Migration("20230929122557_IdEntityGenerator")] - partial class IdEntityGenerator - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.4"); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("DataCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.HasKey("FileId") - .HasName("file_entity_pkey"); - - b.ToTable("file_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.IdEntity", b => - { - b.Property("FileId") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasColumnName("file_id") - .HasDefaultValueSql("hex(randomblob(3))"); - - b.Property("CrashReportId") - .HasColumnType("TEXT") - .HasColumnName("crash_report_id"); - - b.Property("Created") - .HasColumnType("TEXT") - .HasColumnName("created"); - - b.HasKey("FileId"); - - b.HasIndex("CrashReportId"); - - b.ToTable("id_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => - { - b.Property("FileId") - .HasColumnType("TEXT") - .HasColumnName("file_id"); - - b.Property("CrashReportCompressed") - .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); - - b.HasKey("FileId"); - - b.ToTable("json_entity", (string)null); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => - { - b.HasOne("BUTR.CrashReportServer.Models.Database.IdEntity", "Id") - .WithOne() - .HasForeignKey("BUTR.CrashReportServer.Models.Database.FileEntity", "FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Id"); - }); - - modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => - { - b.HasOne("BUTR.CrashReportServer.Models.Database.IdEntity", "Id") - .WithOne() - .HasForeignKey("BUTR.CrashReportServer.Models.Database.JsonEntity", "FileId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/BUTR.CrashReportServer/Migrations/20230929122557_IdEntityGenerator.cs b/src/BUTR.CrashReportServer/Migrations/20230929122557_IdEntityGenerator.cs deleted file mode 100644 index 9fc64bd..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20230929122557_IdEntityGenerator.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - /// - public partial class IdEntityGenerator : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "file_id", - table: "id_entity", - type: "TEXT", - nullable: false, - defaultValueSql: "hex(randomblob(3))", - oldClrType: typeof(string), - oldType: "TEXT"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "file_id", - table: "id_entity", - type: "TEXT", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT", - oldDefaultValueSql: "hex(randomblob(3))"); - } - } -} \ No newline at end of file diff --git a/src/BUTR.CrashReportServer/Migrations/20231002112904_IdEntityVersion.cs b/src/BUTR.CrashReportServer/Migrations/20231002112904_IdEntityVersion.cs deleted file mode 100644 index 8944520..0000000 --- a/src/BUTR.CrashReportServer/Migrations/20231002112904_IdEntityVersion.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace BUTR.CrashReportServer.Migrations -{ - /// - public partial class IdEntityVersion : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "version", - table: "id_entity", - type: "INTEGER", - nullable: false, - defaultValue: (byte) 0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "version", - table: "id_entity"); - } - } -} \ No newline at end of file diff --git a/src/BUTR.CrashReportServer/Migrations/20231002112904_IdEntityVersion.Designer.cs b/src/BUTR.CrashReportServer/Migrations/20240224211446_Initial.Designer.cs similarity index 76% rename from src/BUTR.CrashReportServer/Migrations/20231002112904_IdEntityVersion.Designer.cs rename to src/BUTR.CrashReportServer/Migrations/20240224211446_Initial.Designer.cs index 6482e01..ab8b0ad 100644 --- a/src/BUTR.CrashReportServer/Migrations/20231002112904_IdEntityVersion.Designer.cs +++ b/src/BUTR.CrashReportServer/Migrations/20240224211446_Initial.Designer.cs @@ -5,30 +5,35 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace BUTR.CrashReportServer.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20231002112904_IdEntityVersion")] - partial class IdEntityVersion + [Migration("20240224211446_Initial")] + partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.11"); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => { b.Property("FileId") - .HasColumnType("TEXT") + .HasColumnType("text") .HasColumnName("file_id"); b.Property("DataCompressed") .IsRequired() - .HasColumnType("BLOB") + .HasColumnType("bytea") .HasColumnName("data_compressed"); b.HasKey("FileId") @@ -40,21 +45,19 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.IdEntity", b => { b.Property("FileId") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasColumnName("file_id") - .HasDefaultValueSql("hex(randomblob(3))"); + .HasColumnType("text") + .HasColumnName("file_id"); b.Property("CrashReportId") - .HasColumnType("TEXT") + .HasColumnType("uuid") .HasColumnName("crash_report_id"); - b.Property("Created") - .HasColumnType("TEXT") + b.Property("Created") + .HasColumnType("timestamp with time zone") .HasColumnName("created"); b.Property("Version") - .HasColumnType("INTEGER") + .HasColumnType("smallint") .HasColumnName("version"); b.HasKey("FileId"); @@ -67,13 +70,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => { b.Property("FileId") - .HasColumnType("TEXT") + .HasColumnType("text") .HasColumnName("file_id"); - b.Property("CrashReportCompressed") + b.Property("CrashReport") .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); + .HasColumnType("jsonb") + .HasColumnName("data"); b.HasKey("FileId"); diff --git a/src/BUTR.CrashReportServer/Migrations/20240224211446_Initial.cs b/src/BUTR.CrashReportServer/Migrations/20240224211446_Initial.cs new file mode 100644 index 0000000..b45ff50 --- /dev/null +++ b/src/BUTR.CrashReportServer/Migrations/20240224211446_Initial.cs @@ -0,0 +1,83 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BUTR.CrashReportServer.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "id_entity", + columns: table => new + { + file_id = table.Column(type: "text", nullable: false), + crash_report_id = table.Column(type: "uuid", nullable: false), + version = table.Column(type: "smallint", nullable: false), + created = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_id_entity", x => x.file_id); + }); + + migrationBuilder.CreateTable( + name: "file_entity", + columns: table => new + { + file_id = table.Column(type: "text", nullable: false), + data_compressed = table.Column(type: "bytea", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("file_entity_pkey", x => x.file_id); + table.ForeignKey( + name: "FK_file_entity_id_entity_file_id", + column: x => x.file_id, + principalTable: "id_entity", + principalColumn: "file_id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "json_entity", + columns: table => new + { + file_id = table.Column(type: "text", nullable: false), + data = table.Column(type: "jsonb", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_json_entity", x => x.file_id); + table.ForeignKey( + name: "FK_json_entity_id_entity_file_id", + column: x => x.file_id, + principalTable: "id_entity", + principalColumn: "file_id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_id_entity_crash_report_id", + table: "id_entity", + column: "crash_report_id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "file_entity"); + + migrationBuilder.DropTable( + name: "json_entity"); + + migrationBuilder.DropTable( + name: "id_entity"); + } + } +} diff --git a/src/BUTR.CrashReportServer/Migrations/AppDbContextModelSnapshot.cs b/src/BUTR.CrashReportServer/Migrations/AppDbContextModelSnapshot.cs index db5f343..718bda8 100644 --- a/src/BUTR.CrashReportServer/Migrations/AppDbContextModelSnapshot.cs +++ b/src/BUTR.CrashReportServer/Migrations/AppDbContextModelSnapshot.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -15,17 +16,21 @@ partial class AppDbContextModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.11"); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.FileEntity", b => { b.Property("FileId") - .HasColumnType("TEXT") + .HasColumnType("text") .HasColumnName("file_id"); b.Property("DataCompressed") .IsRequired() - .HasColumnType("BLOB") + .HasColumnType("bytea") .HasColumnName("data_compressed"); b.HasKey("FileId") @@ -37,21 +42,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.IdEntity", b => { b.Property("FileId") - .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasColumnName("file_id") - .HasDefaultValueSql("hex(randomblob(3))"); + .HasColumnType("text") + .HasColumnName("file_id"); b.Property("CrashReportId") - .HasColumnType("TEXT") + .HasColumnType("uuid") .HasColumnName("crash_report_id"); b.Property("Created") - .HasColumnType("TEXT") + .HasColumnType("timestamp with time zone") .HasColumnName("created"); b.Property("Version") - .HasColumnType("INTEGER") + .HasColumnType("smallint") .HasColumnName("version"); b.HasKey("FileId"); @@ -64,13 +67,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BUTR.CrashReportServer.Models.Database.JsonEntity", b => { b.Property("FileId") - .HasColumnType("TEXT") + .HasColumnType("text") .HasColumnName("file_id"); - b.Property("CrashReportCompressed") + b.Property("CrashReport") .IsRequired() - .HasColumnType("BLOB") - .HasColumnName("data_compressed"); + .HasColumnType("jsonb") + .HasColumnName("data"); b.HasKey("FileId");