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