From 7226614b5c3c89fbc8d194240f56601102e31dd7 Mon Sep 17 00:00:00 2001 From: smallbenji Date: Wed, 19 Feb 2025 17:54:16 +0100 Subject: [PATCH] Revert "Adding Blocking to migrations" This reverts commit c8934e53da9f1ca6de3f327e9f89184eb27e7a73. Revert "Adding Blocking to migrations" This reverts commit c8934e53da9f1ca6de3f327e9f89184eb27e7a73. --- ...cs => 20241121135108_DateTime.Designer.cs} | 33 +++++++++++-------- ...lockings.cs => 20241121135108_DateTime.cs} | 32 +++++++++--------- .../Migrations/DataContextModelSnapshot.cs | 29 +++++++++------- pointMaster/Models/Poster.cs | 2 -- 4 files changed, 52 insertions(+), 44 deletions(-) rename pointMaster/Migrations/{20250212090035_Adding blockings.Designer.cs => 20241121135108_DateTime.Designer.cs} (85%) rename pointMaster/Migrations/{20250212090035_Adding blockings.cs => 20241121135108_DateTime.cs} (89%) diff --git a/pointMaster/Migrations/20250212090035_Adding blockings.Designer.cs b/pointMaster/Migrations/20241121135108_DateTime.Designer.cs similarity index 85% rename from pointMaster/Migrations/20250212090035_Adding blockings.Designer.cs rename to pointMaster/Migrations/20241121135108_DateTime.Designer.cs index a5486fa..6cdfa42 100644 --- a/pointMaster/Migrations/20250212090035_Adding blockings.Designer.cs +++ b/pointMaster/Migrations/20241121135108_DateTime.Designer.cs @@ -12,8 +12,8 @@ using pointMaster.Data; namespace pointMaster.Migrations { [DbContext(typeof(DataContext))] - [Migration("20250212090035_Adding blockings")] - partial class Addingblockings + [Migration("20241121135108_DateTime")] + partial class DateTime { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -37,6 +37,7 @@ namespace pointMaster.Migrations .HasColumnType("timestamp with time zone"); b.Property("Name") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -59,9 +60,10 @@ namespace pointMaster.Migrations .HasColumnType("timestamp with time zone"); b.Property("Name") + .IsRequired() .HasColumnType("text"); - b.Property("PatruljeId") + b.Property("PatruljeId") .HasColumnType("integer"); b.HasKey("Id"); @@ -82,13 +84,13 @@ namespace pointMaster.Migrations b.Property("DateCreated") .HasColumnType("timestamp with time zone"); - b.Property("PatruljeId") + b.Property("PatruljeId") .HasColumnType("integer"); b.Property("Points") .HasColumnType("integer"); - b.Property("PosterId") + b.Property("PosterId") .HasColumnType("integer"); b.Property("Turnout") @@ -111,22 +113,19 @@ namespace pointMaster.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("BlockPoint") - .HasColumnType("boolean"); - - b.Property("BlockTurnout") - .HasColumnType("boolean"); - b.Property("DateCreated") .HasColumnType("timestamp with time zone"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Location") + .IsRequired() .HasColumnType("text"); b.Property("Name") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -138,7 +137,9 @@ namespace pointMaster.Migrations { b.HasOne("pointMaster.Models.Patrulje", "Patrulje") .WithMany("PatruljeMedlems") - .HasForeignKey("PatruljeId"); + .HasForeignKey("PatruljeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Patrulje"); }); @@ -147,11 +148,15 @@ namespace pointMaster.Migrations { b.HasOne("pointMaster.Models.Patrulje", "Patrulje") .WithMany("Points") - .HasForeignKey("PatruljeId"); + .HasForeignKey("PatruljeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("pointMaster.Models.Post", "Poster") .WithMany() - .HasForeignKey("PosterId"); + .HasForeignKey("PosterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Patrulje"); diff --git a/pointMaster/Migrations/20250212090035_Adding blockings.cs b/pointMaster/Migrations/20241121135108_DateTime.cs similarity index 89% rename from pointMaster/Migrations/20250212090035_Adding blockings.cs rename to pointMaster/Migrations/20241121135108_DateTime.cs index 0aff272..4721701 100644 --- a/pointMaster/Migrations/20250212090035_Adding blockings.cs +++ b/pointMaster/Migrations/20241121135108_DateTime.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -7,7 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace pointMaster.Migrations { /// - public partial class Addingblockings : Migration + public partial class DateTime : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -18,7 +17,7 @@ namespace pointMaster.Migrations { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: true), + Name = table.Column(type: "text", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => @@ -32,11 +31,9 @@ namespace pointMaster.Migrations { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: true), - Location = table.Column(type: "text", nullable: true), - Description = table.Column(type: "text", nullable: true), - BlockPoint = table.Column(type: "boolean", nullable: false), - BlockTurnout = table.Column(type: "boolean", nullable: false), + Name = table.Column(type: "text", nullable: false), + Location = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => @@ -50,9 +47,9 @@ namespace pointMaster.Migrations { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: true), + Name = table.Column(type: "text", nullable: false), Age = table.Column(type: "integer", nullable: false), - PatruljeId = table.Column(type: "integer", nullable: true), + PatruljeId = table.Column(type: "integer", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => @@ -62,7 +59,8 @@ namespace pointMaster.Migrations name: "FK_PatruljeMedlemmer_Patruljer_PatruljeId", column: x => x.PatruljeId, principalTable: "Patruljer", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -73,8 +71,8 @@ namespace pointMaster.Migrations .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Points = table.Column(type: "integer", nullable: false), Turnout = table.Column(type: "integer", nullable: false), - PatruljeId = table.Column(type: "integer", nullable: true), - PosterId = table.Column(type: "integer", nullable: true), + PatruljeId = table.Column(type: "integer", nullable: false), + PosterId = table.Column(type: "integer", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => @@ -84,12 +82,14 @@ namespace pointMaster.Migrations name: "FK_Points_Patruljer_PatruljeId", column: x => x.PatruljeId, principalTable: "Patruljer", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Points_Poster_PosterId", column: x => x.PosterId, principalTable: "Poster", - principalColumn: "Id"); + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( diff --git a/pointMaster/Migrations/DataContextModelSnapshot.cs b/pointMaster/Migrations/DataContextModelSnapshot.cs index ba63e5d..d400d6a 100644 --- a/pointMaster/Migrations/DataContextModelSnapshot.cs +++ b/pointMaster/Migrations/DataContextModelSnapshot.cs @@ -34,6 +34,7 @@ namespace pointMaster.Migrations .HasColumnType("timestamp with time zone"); b.Property("Name") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -56,9 +57,10 @@ namespace pointMaster.Migrations .HasColumnType("timestamp with time zone"); b.Property("Name") + .IsRequired() .HasColumnType("text"); - b.Property("PatruljeId") + b.Property("PatruljeId") .HasColumnType("integer"); b.HasKey("Id"); @@ -79,13 +81,13 @@ namespace pointMaster.Migrations b.Property("DateCreated") .HasColumnType("timestamp with time zone"); - b.Property("PatruljeId") + b.Property("PatruljeId") .HasColumnType("integer"); b.Property("Points") .HasColumnType("integer"); - b.Property("PosterId") + b.Property("PosterId") .HasColumnType("integer"); b.Property("Turnout") @@ -108,22 +110,19 @@ namespace pointMaster.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("BlockPoint") - .HasColumnType("boolean"); - - b.Property("BlockTurnout") - .HasColumnType("boolean"); - b.Property("DateCreated") .HasColumnType("timestamp with time zone"); b.Property("Description") + .IsRequired() .HasColumnType("text"); b.Property("Location") + .IsRequired() .HasColumnType("text"); b.Property("Name") + .IsRequired() .HasColumnType("text"); b.HasKey("Id"); @@ -135,7 +134,9 @@ namespace pointMaster.Migrations { b.HasOne("pointMaster.Models.Patrulje", "Patrulje") .WithMany("PatruljeMedlems") - .HasForeignKey("PatruljeId"); + .HasForeignKey("PatruljeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Patrulje"); }); @@ -144,11 +145,15 @@ namespace pointMaster.Migrations { b.HasOne("pointMaster.Models.Patrulje", "Patrulje") .WithMany("Points") - .HasForeignKey("PatruljeId"); + .HasForeignKey("PatruljeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("pointMaster.Models.Post", "Poster") .WithMany() - .HasForeignKey("PosterId"); + .HasForeignKey("PosterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.Navigation("Patrulje"); diff --git a/pointMaster/Models/Poster.cs b/pointMaster/Models/Poster.cs index cf4e9a3..eba0aaf 100644 --- a/pointMaster/Models/Poster.cs +++ b/pointMaster/Models/Poster.cs @@ -6,8 +6,6 @@ public string Name { get; set; } public string Location { get; set; } public string Description { get; set; } - public bool BlockPoint { get; set; } - public bool BlockTurnout { get; set; } public DateTime? DateCreated { get; set; } } }