diff --git a/src/MergeDay.Api/Domain/Entities/Bill.cs b/src/MergeDay.Api/Domain/Entities/Bill.cs index 62e5f98..4ad420d 100644 --- a/src/MergeDay.Api/Domain/Entities/Bill.cs +++ b/src/MergeDay.Api/Domain/Entities/Bill.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace MergeDay.Api.Domain.Entities; @@ -9,11 +10,13 @@ public class Bill public Guid ApplicationUserId { get; set; } public ApplicationUser ApplicationUser { get; set; } = null!; + [Required] public required string Name { get; set; } = string.Empty; [Column(TypeName = "decimal(18,2)")] public required decimal Total { get; set; } + [Required] public required string IBAN { get; set; } = string.Empty; public string? Note { get; set; } diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824115058_AddRefreshToken.Designer.cs b/src/MergeDay.Api/Infrastructure/Migrations/20250829165912_InitialPostgres.Designer.cs similarity index 72% rename from src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824115058_AddRefreshToken.Designer.cs rename to src/MergeDay.Api/Infrastructure/Migrations/20250829165912_InitialPostgres.Designer.cs index f9baf28..9c17b9d 100644 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824115058_AddRefreshToken.Designer.cs +++ b/src/MergeDay.Api/Infrastructure/Migrations/20250829165912_InitialPostgres.Designer.cs @@ -1,19 +1,20 @@ // using System; +using System.Collections.Generic; using MergeDay.Api.Infrastructure.Persistence; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace MergeDay.Api.Migrations { [DbContext(typeof(MergeDayDbContext))] - [Migration("20250824115058_AddRefreshToken")] - partial class AddRefreshToken + [Migration("20250829165912_InitialPostgres")] + partial class InitialPostgres { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -21,9 +22,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.19") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + .HasAnnotation("Relational:MaxIdentifierLength", 63); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("MergeDay.Api.Domain.Entities.Absence", b => { @@ -31,30 +32,30 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("bigint"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AuditorNote") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("EndDate") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Kind") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("RequestorNote") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("StartDate") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Status") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("UserId") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.HasKey("Id"); @@ -65,77 +66,81 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("AccessFailedCount") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("Email") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("EmailConfirmed") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("FakturoidClientId") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("FakturoidClientSecret") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("FakturoidSlug") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); - b.Property("IBANs") + b.Property>("IBANs") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text[]"); + + b.Property("Lastname") + .IsRequired() + .HasColumnType("text"); b.Property("LockoutEnabled") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); + .HasColumnType("timestamp with time zone"); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("NormalizedEmail") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("NormalizedUserName") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("PricePerHour") .HasColumnType("decimal(18,2)"); b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("TogglApiToken") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("TwoFactorEnabled") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("UserName") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -144,8 +149,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("NormalizedUserName") .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); + .HasDatabaseName("UserNameIndex"); b.ToTable("AspNetUsers", (string)null); }); @@ -154,34 +158,33 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); + .HasColumnType("uuid"); b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("CreatedAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("IBAN") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("IsPaid") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("Note") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("OrderDate") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("PaidAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Total") .HasColumnType("decimal(18,2)"); @@ -197,20 +200,19 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); + .HasColumnType("uuid"); b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("BillId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("IsPaid") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("PaidAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Price") .HasColumnType("decimal(18,2)"); @@ -228,26 +230,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); + .HasColumnType("uuid"); b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("CreatedAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("ExpiresAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("ReplacedByTokenHash") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("TokenHash") .IsRequired() .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -263,16 +264,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("TogglId") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -285,15 +286,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("bigint"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); - b.Property("UserIds") + b.Property>("UserIds") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text[]"); b.HasKey("Id"); @@ -304,26 +305,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("Name") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("NormalizedName") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); b.HasIndex("NormalizedName") .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); + .HasDatabaseName("RoleNameIndex"); b.ToTable("AspNetRoles", (string)null); }); @@ -332,18 +332,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("RoleId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("Id"); @@ -356,18 +356,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("Id"); @@ -379,16 +379,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("LoginProvider", "ProviderKey"); @@ -400,10 +400,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("RoleId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("UserId", "RoleId"); @@ -415,16 +415,16 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("Name") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("Value") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.HasKey("UserId", "LoginProvider", "Name"); diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823101554_BillOnDeleteBehvaiourFix.cs b/src/MergeDay.Api/Infrastructure/Migrations/20250829165912_InitialPostgres.cs similarity index 59% rename from src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823101554_BillOnDeleteBehvaiourFix.cs rename to src/MergeDay.Api/Infrastructure/Migrations/20250829165912_InitialPostgres.cs index 931cd0f..30f4691 100644 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823101554_BillOnDeleteBehvaiourFix.cs +++ b/src/MergeDay.Api/Infrastructure/Migrations/20250829165912_InitialPostgres.cs @@ -1,12 +1,14 @@ using System; +using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace MergeDay.Api.Migrations { /// - public partial class BillOnDeleteBehvaiourFix : Migration + public partial class InitialPostgres : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -16,14 +18,14 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: table => new { Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - UserId = table.Column(type: "nvarchar(max)", nullable: false), - StartDate = table.Column(type: "datetime2", nullable: false), - EndDate = table.Column(type: "datetime2", nullable: false), - Kind = table.Column(type: "int", nullable: false), - Status = table.Column(type: "int", nullable: false), - RequestorNote = table.Column(type: "nvarchar(max)", nullable: false), - AuditorNote = table.Column(type: "nvarchar(max)", nullable: true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "text", nullable: false), + StartDate = table.Column(type: "timestamp with time zone", nullable: false), + EndDate = table.Column(type: "timestamp with time zone", nullable: false), + Kind = table.Column(type: "integer", nullable: false), + Status = table.Column(type: "integer", nullable: false), + RequestorNote = table.Column(type: "text", nullable: false), + AuditorNote = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -34,10 +36,10 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetRoles", columns: table => new { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -48,27 +50,29 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetUsers", columns: table => new { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TogglApiToken = table.Column(type: "nvarchar(max)", nullable: true), - FakturoidSlug = table.Column(type: "nvarchar(max)", nullable: true), - FakturoidClientId = table.Column(type: "nvarchar(max)", nullable: true), - FakturoidClientSecret = table.Column(type: "nvarchar(max)", nullable: true), - PricePerHour = table.Column(type: "decimal(18,2)", nullable: true), - IBANs = table.Column(type: "nvarchar(max)", nullable: false), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "bit", nullable: false), - PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), - SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), - PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), - TwoFactorEnabled = table.Column(type: "bit", nullable: false), - LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), - LockoutEnabled = table.Column(type: "bit", nullable: false), - AccessFailedCount = table.Column(type: "int", nullable: false) + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Lastname = table.Column(type: "text", nullable: false), + TogglApiToken = table.Column(type: "text", nullable: true), + FakturoidSlug = table.Column(type: "text", nullable: true), + FakturoidClientId = table.Column(type: "text", nullable: true), + FakturoidClientSecret = table.Column(type: "text", nullable: true), + PricePerHour = table.Column(type: "numeric(18,2)", nullable: true), + IBANs = table.Column>(type: "text[]", nullable: false), + UserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedUserName = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + Email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + NormalizedEmail = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) }, constraints: table => { @@ -79,10 +83,10 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "TogglProjects", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - TogglId = table.Column(type: "int", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TogglId = table.Column(type: "integer", nullable: false), + Name = table.Column(type: "text", nullable: false) }, constraints: table => { @@ -94,9 +98,9 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: table => new { Id = table.Column(type: "bigint", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Name = table.Column(type: "nvarchar(max)", nullable: false), - UserIds = table.Column(type: "nvarchar(max)", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + UserIds = table.Column>(type: "text[]", nullable: false) }, constraints: table => { @@ -107,11 +111,11 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetRoleClaims", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - ClaimType = table.Column(type: "nvarchar(max)", nullable: true), - ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -128,11 +132,11 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetUserClaims", columns: table => new { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - ClaimType = table.Column(type: "nvarchar(max)", nullable: true), - ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "uuid", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -149,10 +153,10 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetUserLogins", columns: table => new { - LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), - ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), - ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: false) + LoginProvider = table.Column(type: "text", nullable: false), + ProviderKey = table.Column(type: "text", nullable: false), + ProviderDisplayName = table.Column(type: "text", nullable: true), + UserId = table.Column(type: "uuid", nullable: false) }, constraints: table => { @@ -169,8 +173,8 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetUserRoles", columns: table => new { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false) + UserId = table.Column(type: "uuid", nullable: false), + RoleId = table.Column(type: "uuid", nullable: false) }, constraints: table => { @@ -193,10 +197,10 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "AspNetUserTokens", columns: table => new { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), - Name = table.Column(type: "nvarchar(450)", nullable: false), - Value = table.Column(type: "nvarchar(max)", nullable: true) + UserId = table.Column(type: "uuid", nullable: false), + LoginProvider = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Value = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -213,16 +217,16 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "Bills", columns: table => new { - Id = table.Column(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWSEQUENTIALID()"), - ApplicationUserId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Total = table.Column(type: "decimal(18,2)", nullable: false), - IBAN = table.Column(type: "nvarchar(max)", nullable: false), - Note = table.Column(type: "nvarchar(max)", nullable: true), - CreatedAt = table.Column(type: "datetime2", nullable: false), - OrderDate = table.Column(type: "datetime2", nullable: false), - PaidAt = table.Column(type: "datetime2", nullable: true), - IsPaid = table.Column(type: "bit", nullable: false) + Id = table.Column(type: "uuid", nullable: false), + ApplicationUserId = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Total = table.Column(type: "numeric(18,2)", nullable: false), + IBAN = table.Column(type: "text", nullable: false), + Note = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + OrderDate = table.Column(type: "timestamp with time zone", nullable: false), + PaidAt = table.Column(type: "timestamp with time zone", nullable: true), + IsPaid = table.Column(type: "boolean", nullable: false) }, constraints: table => { @@ -234,16 +238,38 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Id"); }); + migrationBuilder.CreateTable( + name: "RefreshTokens", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + TokenHash = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), + ExpiresAt = table.Column(type: "timestamp with time zone", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + ReplacedByTokenHash = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), + ApplicationUserId = table.Column(type: "uuid", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RefreshTokens", x => x.Id); + table.ForeignKey( + name: "FK_RefreshTokens_AspNetUsers_ApplicationUserId", + column: x => x.ApplicationUserId, + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "BillItems", columns: table => new { - Id = table.Column(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWSEQUENTIALID()"), - BillId = table.Column(type: "uniqueidentifier", nullable: false), - ApplicationUserId = table.Column(type: "uniqueidentifier", nullable: false), - Price = table.Column(type: "decimal(18,2)", nullable: false), - IsPaid = table.Column(type: "bit", nullable: false), - PaidAt = table.Column(type: "datetime2", nullable: true) + Id = table.Column(type: "uuid", nullable: false), + BillId = table.Column(type: "uuid", nullable: false), + ApplicationUserId = table.Column(type: "uuid", nullable: false), + Price = table.Column(type: "numeric(18,2)", nullable: false), + IsPaid = table.Column(type: "boolean", nullable: false), + PaidAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { @@ -269,8 +295,7 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "RoleNameIndex", table: "AspNetRoles", column: "NormalizedName", - unique: true, - filter: "[NormalizedName] IS NOT NULL"); + unique: true); migrationBuilder.CreateIndex( name: "IX_AspNetUserClaims_UserId", @@ -296,8 +321,7 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "UserNameIndex", table: "AspNetUsers", column: "NormalizedUserName", - unique: true, - filter: "[NormalizedUserName] IS NOT NULL"); + unique: true); migrationBuilder.CreateIndex( name: "IX_BillItems_ApplicationUserId", @@ -313,6 +337,17 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "IX_Bills_ApplicationUserId", table: "Bills", column: "ApplicationUserId"); + + migrationBuilder.CreateIndex( + name: "IX_RefreshTokens_ApplicationUserId", + table: "RefreshTokens", + column: "ApplicationUserId"); + + migrationBuilder.CreateIndex( + name: "IX_RefreshTokens_TokenHash", + table: "RefreshTokens", + column: "TokenHash", + unique: true); } /// @@ -339,6 +374,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "BillItems"); + migrationBuilder.DropTable( + name: "RefreshTokens"); + migrationBuilder.DropTable( name: "TogglProjects"); diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/MergeDayDbContextModelSnapshot.cs b/src/MergeDay.Api/Infrastructure/Migrations/MergeDayDbContextModelSnapshot.cs similarity index 72% rename from src/MergeDay.Api/Infrastructure/Persistence/Migrations/MergeDayDbContextModelSnapshot.cs rename to src/MergeDay.Api/Infrastructure/Migrations/MergeDayDbContextModelSnapshot.cs index 4df3958..cd2ab3e 100644 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/MergeDayDbContextModelSnapshot.cs +++ b/src/MergeDay.Api/Infrastructure/Migrations/MergeDayDbContextModelSnapshot.cs @@ -1,10 +1,11 @@ // using System; +using System.Collections.Generic; using MergeDay.Api.Infrastructure.Persistence; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -18,9 +19,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.19") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + .HasAnnotation("Relational:MaxIdentifierLength", 63); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("MergeDay.Api.Domain.Entities.Absence", b => { @@ -28,30 +29,30 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("bigint"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AuditorNote") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("EndDate") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Kind") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("RequestorNote") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("StartDate") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Status") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("UserId") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.HasKey("Id"); @@ -62,81 +63,81 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("AccessFailedCount") - .HasColumnType("int"); + .HasColumnType("integer"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("Email") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("EmailConfirmed") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("FakturoidClientId") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("FakturoidClientSecret") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("FakturoidSlug") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); - b.Property("IBANs") + b.Property>("IBANs") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text[]"); b.Property("Lastname") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("LockoutEnabled") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); + .HasColumnType("timestamp with time zone"); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("NormalizedEmail") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("NormalizedUserName") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("PricePerHour") .HasColumnType("decimal(18,2)"); b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("TogglApiToken") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("TwoFactorEnabled") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("UserName") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -145,8 +146,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("NormalizedUserName") .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); + .HasDatabaseName("UserNameIndex"); b.ToTable("AspNetUsers", (string)null); }); @@ -155,34 +155,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); + .HasColumnType("uuid"); b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("CreatedAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("IBAN") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("IsPaid") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("Note") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("OrderDate") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("PaidAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Total") .HasColumnType("decimal(18,2)"); @@ -198,20 +197,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); + .HasColumnType("uuid"); b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("BillId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("IsPaid") - .HasColumnType("bit"); + .HasColumnType("boolean"); b.Property("PaidAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("Price") .HasColumnType("decimal(18,2)"); @@ -229,26 +227,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); + .HasColumnType("uuid"); b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("CreatedAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("ExpiresAt") - .HasColumnType("datetime2"); + .HasColumnType("timestamp with time zone"); b.Property("ReplacedByTokenHash") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("TokenHash") .IsRequired() .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -264,16 +261,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("TogglId") - .HasColumnType("int"); + .HasColumnType("integer"); b.HasKey("Id"); @@ -286,15 +283,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("bigint"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); - b.Property("UserIds") + b.Property>("UserIds") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text[]"); b.HasKey("Id"); @@ -305,26 +302,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("Name") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.Property("NormalizedName") .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); b.HasIndex("NormalizedName") .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); + .HasDatabaseName("RoleNameIndex"); b.ToTable("AspNetRoles", (string)null); }); @@ -333,18 +329,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("RoleId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("Id"); @@ -357,18 +353,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("int"); + .HasColumnType("integer"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("Id"); @@ -380,16 +376,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("LoginProvider", "ProviderKey"); @@ -401,10 +397,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("RoleId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.HasKey("UserId", "RoleId"); @@ -416,16 +412,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId") - .HasColumnType("uniqueidentifier"); + .HasColumnType("uuid"); b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("Name") - .HasColumnType("nvarchar(450)"); + .HasColumnType("text"); b.Property("Value") - .HasColumnType("nvarchar(max)"); + .HasColumnType("text"); b.HasKey("UserId", "LoginProvider", "Name"); diff --git a/src/MergeDay.Api/Infrastructure/Persistence/MergeDayDbContext.cs b/src/MergeDay.Api/Infrastructure/Persistence/MergeDayDbContext.cs index 3d56486..c0ee579 100644 --- a/src/MergeDay.Api/Infrastructure/Persistence/MergeDayDbContext.cs +++ b/src/MergeDay.Api/Infrastructure/Persistence/MergeDayDbContext.cs @@ -22,13 +22,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(e => { - e.HasKey(x => x.Id); - e.Property(x => x.Id).HasDefaultValueSql("NEWSEQUENTIALID()"); - - e.Property(x => x.Name).IsRequired(); - e.Property(x => x.IBAN).IsRequired(); - e.Property(x => x.Total).HasColumnType("decimal(18,2)"); - e.HasOne(x => x.ApplicationUser) .WithMany() .HasForeignKey(x => x.ApplicationUserId) @@ -44,10 +37,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(e => { - e.HasKey(x => x.Id); - e.Property(x => x.Id).HasDefaultValueSql("NEWSEQUENTIALID()"); - e.Property(x => x.Price).HasColumnType("decimal(18,2)"); - e.HasOne(x => x.ApplicationUser) .WithMany() .HasForeignKey(x => x.ApplicationUserId) @@ -59,11 +48,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(e => { - e.HasKey(x => x.Id); - e.Property(x => x.Id).HasDefaultValueSql("NEWSEQUENTIALID()"); - e.Property(x => x.TokenHash).IsRequired().HasMaxLength(256); - e.Property(x => x.ReplacedByTokenHash).HasMaxLength(256); - e.HasIndex(x => x.TokenHash).IsUnique(); e.HasIndex(x => x.ApplicationUserId); diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823101554_BillOnDeleteBehvaiourFix.Designer.cs b/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823101554_BillOnDeleteBehvaiourFix.Designer.cs deleted file mode 100644 index 046c2ef..0000000 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823101554_BillOnDeleteBehvaiourFix.Designer.cs +++ /dev/null @@ -1,483 +0,0 @@ -// -using System; -using MergeDay.Api.Infrastructure.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MergeDay.Api.Migrations -{ - [DbContext(typeof(MergeDayDbContext))] - [Migration("20250823101554_BillOnDeleteBehvaiourFix")] - partial class BillOnDeleteBehvaiourFix - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.19") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Absence", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AuditorNote") - .HasColumnType("nvarchar(max)"); - - b.Property("EndDate") - .HasColumnType("datetime2"); - - b.Property("Kind") - .HasColumnType("int"); - - b.Property("RequestorNote") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StartDate") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Absences"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FakturoidClientId") - .HasColumnType("nvarchar(max)"); - - b.Property("FakturoidClientSecret") - .HasColumnType("nvarchar(max)"); - - b.Property("FakturoidSlug") - .HasColumnType("nvarchar(max)"); - - b.Property("IBANs") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("PricePerHour") - .HasColumnType("decimal(18,2)"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TogglApiToken") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("IBAN") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsPaid") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Note") - .HasColumnType("nvarchar(max)"); - - b.Property("OrderDate") - .HasColumnType("datetime2"); - - b.Property("PaidAt") - .HasColumnType("datetime2"); - - b.Property("Total") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("Bills"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.BillItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("BillId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsPaid") - .HasColumnType("bit"); - - b.Property("PaidAt") - .HasColumnType("datetime2"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("BillId"); - - b.ToTable("BillItems"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.TogglProject", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TogglId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("TogglProjects"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Workspace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIds") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Workspaces"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ApplicationUser"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.BillItem", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("MergeDay.Api.Domain.Entities.Bill", "Bill") - .WithMany("Items") - .HasForeignKey("BillId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Bill"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.Navigation("Items"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823104157_AddUserName.Designer.cs b/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823104157_AddUserName.Designer.cs deleted file mode 100644 index efcbf7f..0000000 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823104157_AddUserName.Designer.cs +++ /dev/null @@ -1,487 +0,0 @@ -// -using System; -using MergeDay.Api.Infrastructure.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MergeDay.Api.Migrations -{ - [DbContext(typeof(MergeDayDbContext))] - [Migration("20250823104157_AddUserName")] - partial class AddUserName - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.19") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Absence", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AuditorNote") - .HasColumnType("nvarchar(max)"); - - b.Property("EndDate") - .HasColumnType("datetime2"); - - b.Property("Kind") - .HasColumnType("int"); - - b.Property("RequestorNote") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StartDate") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Absences"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FakturoidClientId") - .HasColumnType("nvarchar(max)"); - - b.Property("FakturoidClientSecret") - .HasColumnType("nvarchar(max)"); - - b.Property("FakturoidSlug") - .HasColumnType("nvarchar(max)"); - - b.Property("IBANs") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("PricePerHour") - .HasColumnType("decimal(18,2)"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TogglApiToken") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("IBAN") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsPaid") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Note") - .HasColumnType("nvarchar(max)"); - - b.Property("OrderDate") - .HasColumnType("datetime2"); - - b.Property("PaidAt") - .HasColumnType("datetime2"); - - b.Property("Total") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("Bills"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.BillItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("BillId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsPaid") - .HasColumnType("bit"); - - b.Property("PaidAt") - .HasColumnType("datetime2"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("BillId"); - - b.ToTable("BillItems"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.TogglProject", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TogglId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("TogglProjects"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Workspace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIds") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Workspaces"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ApplicationUser"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.BillItem", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("MergeDay.Api.Domain.Entities.Bill", "Bill") - .WithMany("Items") - .HasForeignKey("BillId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Bill"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.Navigation("Items"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823104157_AddUserName.cs b/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823104157_AddUserName.cs deleted file mode 100644 index 687fed6..0000000 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250823104157_AddUserName.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MergeDay.Api.Migrations -{ - /// - public partial class AddUserName : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Name", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Name", - table: "AspNetUsers"); - } - } -} diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824115058_AddRefreshToken.cs b/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824115058_AddRefreshToken.cs deleted file mode 100644 index 6b759e6..0000000 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824115058_AddRefreshToken.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MergeDay.Api.Migrations -{ - /// - public partial class AddRefreshToken : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "RefreshTokens", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false, defaultValueSql: "NEWSEQUENTIALID()"), - TokenHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ExpiresAt = table.Column(type: "datetime2", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false), - ReplacedByTokenHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ApplicationUserId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_RefreshTokens", x => x.Id); - table.ForeignKey( - name: "FK_RefreshTokens_AspNetUsers_ApplicationUserId", - column: x => x.ApplicationUserId, - principalTable: "AspNetUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_RefreshTokens_ApplicationUserId", - table: "RefreshTokens", - column: "ApplicationUserId"); - - migrationBuilder.CreateIndex( - name: "IX_RefreshTokens_TokenHash", - table: "RefreshTokens", - column: "TokenHash", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "RefreshTokens"); - } - } -} diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824191501_AddUserLastname.Designer.cs b/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824191501_AddUserLastname.Designer.cs deleted file mode 100644 index e423c3c..0000000 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824191501_AddUserLastname.Designer.cs +++ /dev/null @@ -1,542 +0,0 @@ -// -using System; -using MergeDay.Api.Infrastructure.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace MergeDay.Api.Migrations -{ - [DbContext(typeof(MergeDayDbContext))] - [Migration("20250824191501_AddUserLastname")] - partial class AddUserLastname - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.19") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Absence", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AuditorNote") - .HasColumnType("nvarchar(max)"); - - b.Property("EndDate") - .HasColumnType("datetime2"); - - b.Property("Kind") - .HasColumnType("int"); - - b.Property("RequestorNote") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("StartDate") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Absences"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.ApplicationUser", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("FakturoidClientId") - .HasColumnType("nvarchar(max)"); - - b.Property("FakturoidClientSecret") - .HasColumnType("nvarchar(max)"); - - b.Property("FakturoidSlug") - .HasColumnType("nvarchar(max)"); - - b.Property("IBANs") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Lastname") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("PricePerHour") - .HasColumnType("decimal(18,2)"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TogglApiToken") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("IBAN") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsPaid") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Note") - .HasColumnType("nvarchar(max)"); - - b.Property("OrderDate") - .HasColumnType("datetime2"); - - b.Property("PaidAt") - .HasColumnType("datetime2"); - - b.Property("Total") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.ToTable("Bills"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.BillItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("BillId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsPaid") - .HasColumnType("bit"); - - b.Property("PaidAt") - .HasColumnType("datetime2"); - - b.Property("Price") - .HasColumnType("decimal(18,2)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("BillId"); - - b.ToTable("BillItems"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.RefreshToken", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier") - .HasDefaultValueSql("NEWSEQUENTIALID()"); - - b.Property("ApplicationUserId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("ExpiresAt") - .HasColumnType("datetime2"); - - b.Property("ReplacedByTokenHash") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("TokenHash") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("ApplicationUserId"); - - b.HasIndex("TokenHash") - .IsUnique(); - - b.ToTable("RefreshTokens"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.TogglProject", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TogglId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("TogglProjects"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Workspace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserIds") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Workspaces"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex") - .HasFilter("[NormalizedName] IS NOT NULL"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ApplicationUser"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.BillItem", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany() - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.HasOne("MergeDay.Api.Domain.Entities.Bill", "Bill") - .WithMany("Items") - .HasForeignKey("BillId") - .OnDelete(DeleteBehavior.NoAction) - .IsRequired(); - - b.Navigation("ApplicationUser"); - - b.Navigation("Bill"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.RefreshToken", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", "ApplicationUser") - .WithMany("RefreshTokens") - .HasForeignKey("ApplicationUserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ApplicationUser"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("MergeDay.Api.Domain.Entities.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.ApplicationUser", b => - { - b.Navigation("RefreshTokens"); - }); - - modelBuilder.Entity("MergeDay.Api.Domain.Entities.Bill", b => - { - b.Navigation("Items"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824191501_AddUserLastname.cs b/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824191501_AddUserLastname.cs deleted file mode 100644 index 47e7ced..0000000 --- a/src/MergeDay.Api/Infrastructure/Persistence/Migrations/20250824191501_AddUserLastname.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace MergeDay.Api.Migrations -{ - /// - public partial class AddUserLastname : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Lastname", - table: "AspNetUsers", - type: "nvarchar(max)", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Lastname", - table: "AspNetUsers"); - } - } -} diff --git a/src/MergeDay.Api/MergeDay.Api.csproj b/src/MergeDay.Api/MergeDay.Api.csproj index 508600b..be7e3d7 100644 --- a/src/MergeDay.Api/MergeDay.Api.csproj +++ b/src/MergeDay.Api/MergeDay.Api.csproj @@ -21,8 +21,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive true - + diff --git a/src/MergeDay.Api/Program.cs b/src/MergeDay.Api/Program.cs index 0edf7c4..291a9cf 100644 --- a/src/MergeDay.Api/Program.cs +++ b/src/MergeDay.Api/Program.cs @@ -43,7 +43,11 @@ }); builder.Services.AddEndpoints(typeof(Program).Assembly); builder.Services.AddDbContext(opt => - opt.UseSqlServer(builder.Configuration.GetConnectionString("MergeDayDb"))); + opt.UseNpgsql( + builder.Configuration.GetConnectionString("MergeDayDb"), + npg => npg.EnableRetryOnFailure() + )); + builder.Services .AddIdentity>(options => {