From ac2b6b2c81d4801da98c4257b587c443273a4b30 Mon Sep 17 00:00:00 2001 From: mcmuzzle Date: Thu, 5 Sep 2024 23:45:05 +0200 Subject: [PATCH] Migration vers postgres - suppression de sqlite - ajout de postgres --- .gitignore | 5 +- .../architecture-projet.adoc | 0 .../developpement-livraison.adoc | 0 .../installation-poste.adoc | 23 +++++ documentation/index.adoc | 27 +++++- src/LudikZoneBlazor/Data/app.db | Bin 102400 -> 0 bytes src/LudikZoneBlazor/LudikZoneBlazor.csproj | 2 +- .../20240906111336_Init.Designer.cs} | 91 ++++++++++-------- .../20240906111336_Init.cs} | 81 ++++++++-------- .../ApplicationDbContextModelSnapshot.cs | 87 +++++++++-------- src/LudikZoneBlazor/Program.cs | 14 ++- .../appsettings.Development.json | 22 +++-- 12 files changed, 220 insertions(+), 132 deletions(-) create mode 100644 documentation/documentation_technique/architecture-projet.adoc create mode 100644 documentation/documentation_technique/developpement-livraison.adoc create mode 100644 documentation/documentation_technique/installation-poste.adoc delete mode 100644 src/LudikZoneBlazor/Data/app.db rename src/LudikZoneBlazor/{Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs => Migrations/20240906111336_Init.Designer.cs} (75%) rename src/LudikZoneBlazor/{Data/Migrations/00000000000000_CreateIdentitySchema.cs => Migrations/20240906111336_Init.cs} (73%) rename src/LudikZoneBlazor/{Data => }/Migrations/ApplicationDbContextModelSnapshot.cs (75%) diff --git a/.gitignore b/.gitignore index a395674..17e658c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,7 @@ bin obj report tools/ -TestResults \ No newline at end of file +TestResults + +#docker data +/docker-dev/data \ No newline at end of file diff --git a/documentation/documentation_technique/architecture-projet.adoc b/documentation/documentation_technique/architecture-projet.adoc new file mode 100644 index 0000000..e69de29 diff --git a/documentation/documentation_technique/developpement-livraison.adoc b/documentation/documentation_technique/developpement-livraison.adoc new file mode 100644 index 0000000..e69de29 diff --git a/documentation/documentation_technique/installation-poste.adoc b/documentation/documentation_technique/installation-poste.adoc new file mode 100644 index 0000000..f3b4cf7 --- /dev/null +++ b/documentation/documentation_technique/installation-poste.adoc @@ -0,0 +1,23 @@ +=== Prérequis + +* DotNet 8 +* Docker (26.0.2 minimum recommandé) +* Docker Compose (2.26.1 minimum recommandé) + + +=== Cloner le dépot + +=== Lancer les containers + +[,sh] +---- +docker compose -f .\docker-dev\compose.yml -p ludik-zone up -d +---- + +=== Migrer la bdd + +Lors de la migration de la BDD, les données de connections seront celles du *appsettings.Development.json* +[,sh] +---- +dotnet ef database update --project .\src\LudikZoneBlazor\LudikZoneBlazor.csproj +---- diff --git a/documentation/index.adoc b/documentation/index.adoc index 70c379b..132d468 100644 --- a/documentation/index.adoc +++ b/documentation/index.adoc @@ -1 +1,26 @@ -Hello world \ No newline at end of file += Ludik zone documentation (DEX) +:source-highlighter: pygments +:source-language: bash +:doctype: book +:source-highlighter: rouge +:toc: macro +:toc-title: Table des matières + +toc::[] + +== Présentation + +Le projet Ludik zone est un projet open source ayant comme objectif de créer un portait hébergeant différent jeux en tour par tour. + + +== Instalation du poste de dev + +include::documentation_technique/installation-poste.adoc[] + +== Architecture du projet + +include::documentation_technique/architecture-projet.adoc[] + +== Developpement et livraison + +include::documentation_technique/developpement-livraison.adoc[] diff --git a/src/LudikZoneBlazor/Data/app.db b/src/LudikZoneBlazor/Data/app.db deleted file mode 100644 index e799a27444236ec4bde77e012adfc02fee0ab47c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 102400 zcmeI5&u`mC7RN<9mMkZ>lBS8a=x)o>i){o)j(^+1B1jmSjulIkB2kW=B2a0Gw$(_Y zBT7jebPul60`0NbTd~0Y1AFXg(c>O^-CnxK0(;q>_Yk0$o#7Ajhsnr6;)PRv2{|F> z$D22w_vX!z9LvQ!nOa+6H`P`{ZnM*&v!TAe&<&Oig+hJg=N8dyRoT-4>a&Sej z8irJ=iy@dx?7ue>i6@iH=W1Kts4GTGB~58b>I0>zd9Pz;%MyPxBUl}@ixbJiLo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LudikZoneBlazor.csproj +++ b/src/LudikZoneBlazor/LudikZoneBlazor.csproj @@ -15,10 +15,10 @@ - + diff --git a/src/LudikZoneBlazor/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs b/src/LudikZoneBlazor/Migrations/20240906111336_Init.Designer.cs similarity index 75% rename from src/LudikZoneBlazor/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs rename to src/LudikZoneBlazor/Migrations/20240906111336_Init.Designer.cs index 2ab8991..80fc07a 100644 --- a/src/LudikZoneBlazor/Data/Migrations/00000000000000_CreateIdentitySchema.Designer.cs +++ b/src/LudikZoneBlazor/Migrations/20240906111336_Init.Designer.cs @@ -1,76 +1,81 @@ -// +// using System; using LudikZoneBlazor.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace LudikZoneBlazor.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("00000000000000_CreateIdentitySchema")] - partial class CreateIdentitySchema + [Migration("20240906111336_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("LudikZoneBlazor.Data.ApplicationUser", b => { b.Property("Id") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("AccessFailedCount") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Email") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("EmailConfirmed") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("LockoutEnabled") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("LockoutEnd") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("NormalizedEmail") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("NormalizedUserName") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("PasswordHash") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("PhoneNumber") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("PhoneNumberConfirmed") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("SecurityStamp") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("TwoFactorEnabled") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("UserName") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -87,19 +92,19 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { b.Property("Id") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Name") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("NormalizedName") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -114,17 +119,19 @@ namespace LudikZoneBlazor.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("RoleId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("Id"); @@ -137,17 +144,19 @@ namespace LudikZoneBlazor.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("UserId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("Id"); @@ -159,17 +168,17 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ProviderKey") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ProviderDisplayName") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("UserId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("LoginProvider", "ProviderKey"); @@ -181,10 +190,10 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("RoleId") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("UserId", "RoleId"); @@ -196,16 +205,16 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("LoginProvider") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Name") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Value") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("UserId", "LoginProvider", "Name"); diff --git a/src/LudikZoneBlazor/Data/Migrations/00000000000000_CreateIdentitySchema.cs b/src/LudikZoneBlazor/Migrations/20240906111336_Init.cs similarity index 73% rename from src/LudikZoneBlazor/Data/Migrations/00000000000000_CreateIdentitySchema.cs rename to src/LudikZoneBlazor/Migrations/20240906111336_Init.cs index ffe8b34..e02f275 100644 --- a/src/LudikZoneBlazor/Data/Migrations/00000000000000_CreateIdentitySchema.cs +++ b/src/LudikZoneBlazor/Migrations/20240906111336_Init.cs @@ -1,12 +1,13 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace LudikZoneBlazor.Migrations { /// - public partial class CreateIdentitySchema : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -15,10 +16,10 @@ namespace LudikZoneBlazor.Migrations name: "AspNetRoles", columns: table => new { - Id = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", maxLength: 256, nullable: true), - NormalizedName = table.Column(type: "TEXT", maxLength: 256, nullable: true), - ConcurrencyStamp = table.Column(type: "TEXT", nullable: true) + Id = table.Column(type: "text", 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 => { @@ -29,21 +30,21 @@ namespace LudikZoneBlazor.Migrations name: "AspNetUsers", columns: table => new { - Id = table.Column(type: "TEXT", nullable: false), - UserName = table.Column(type: "TEXT", maxLength: 256, nullable: true), - NormalizedUserName = table.Column(type: "TEXT", maxLength: 256, nullable: true), - Email = table.Column(type: "TEXT", maxLength: 256, nullable: true), - NormalizedEmail = table.Column(type: "TEXT", maxLength: 256, nullable: true), - EmailConfirmed = table.Column(type: "INTEGER", 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: "INTEGER", nullable: false), - TwoFactorEnabled = table.Column(type: "INTEGER", nullable: false), - LockoutEnd = table.Column(type: "TEXT", nullable: true), - LockoutEnabled = table.Column(type: "INTEGER", nullable: false), - AccessFailedCount = table.Column(type: "INTEGER", nullable: false) + Id = 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 => { @@ -54,11 +55,11 @@ namespace LudikZoneBlazor.Migrations name: "AspNetRoleClaims", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - RoleId = table.Column(type: "TEXT", nullable: false), - ClaimType = table.Column(type: "TEXT", nullable: true), - ClaimValue = table.Column(type: "TEXT", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RoleId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -75,11 +76,11 @@ namespace LudikZoneBlazor.Migrations name: "AspNetUserClaims", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - UserId = table.Column(type: "TEXT", nullable: false), - ClaimType = table.Column(type: "TEXT", nullable: true), - ClaimValue = table.Column(type: "TEXT", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "text", nullable: false), + ClaimType = table.Column(type: "text", nullable: true), + ClaimValue = table.Column(type: "text", nullable: true) }, constraints: table => { @@ -96,10 +97,10 @@ namespace LudikZoneBlazor.Migrations name: "AspNetUserLogins", columns: table => new { - 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: "TEXT", 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: "text", nullable: false) }, constraints: table => { @@ -116,8 +117,8 @@ namespace LudikZoneBlazor.Migrations name: "AspNetUserRoles", columns: table => new { - UserId = table.Column(type: "TEXT", nullable: false), - RoleId = table.Column(type: "TEXT", nullable: false) + UserId = table.Column(type: "text", nullable: false), + RoleId = table.Column(type: "text", nullable: false) }, constraints: table => { @@ -140,10 +141,10 @@ namespace LudikZoneBlazor.Migrations name: "AspNetUserTokens", columns: table => new { - UserId = table.Column(type: "TEXT", nullable: false), - LoginProvider = table.Column(type: "TEXT", nullable: false), - Name = table.Column(type: "TEXT", nullable: false), - Value = table.Column(type: "TEXT", nullable: true) + UserId = table.Column(type: "text", 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 => { diff --git a/src/LudikZoneBlazor/Data/Migrations/ApplicationDbContextModelSnapshot.cs b/src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs similarity index 75% rename from src/LudikZoneBlazor/Data/Migrations/ApplicationDbContextModelSnapshot.cs rename to src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs index 6c1013a..087db82 100644 --- a/src/LudikZoneBlazor/Data/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/LudikZoneBlazor/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1,9 +1,10 @@ -// +// using System; using LudikZoneBlazor.Data; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -15,59 +16,63 @@ namespace LudikZoneBlazor.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("LudikZoneBlazor.Data.ApplicationUser", b => { b.Property("Id") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("AccessFailedCount") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Email") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("EmailConfirmed") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("LockoutEnabled") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("LockoutEnd") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("NormalizedEmail") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("NormalizedUserName") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("PasswordHash") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("PhoneNumber") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("PhoneNumberConfirmed") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("SecurityStamp") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("TwoFactorEnabled") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("UserName") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -84,19 +89,19 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { b.Property("Id") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ConcurrencyStamp") .IsConcurrencyToken() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Name") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.Property("NormalizedName") .HasMaxLength(256) - .HasColumnType("TEXT"); + .HasColumnType("character varying(256)"); b.HasKey("Id"); @@ -111,17 +116,19 @@ namespace LudikZoneBlazor.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("RoleId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("Id"); @@ -134,17 +141,19 @@ namespace LudikZoneBlazor.Migrations { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("ClaimType") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ClaimValue") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("UserId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("Id"); @@ -156,17 +165,17 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ProviderKey") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("ProviderDisplayName") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("UserId") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("LoginProvider", "ProviderKey"); @@ -178,10 +187,10 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { b.Property("UserId") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("RoleId") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("UserId", "RoleId"); @@ -193,16 +202,16 @@ namespace LudikZoneBlazor.Migrations modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.Property("UserId") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("LoginProvider") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Name") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Value") - .HasColumnType("TEXT"); + .HasColumnType("text"); b.HasKey("UserId", "LoginProvider", "Name"); diff --git a/src/LudikZoneBlazor/Program.cs b/src/LudikZoneBlazor/Program.cs index 328156d..fa4f86e 100644 --- a/src/LudikZoneBlazor/Program.cs +++ b/src/LudikZoneBlazor/Program.cs @@ -5,6 +5,7 @@ using MudBlazor.Services; using LudikZoneBlazor.Components; using LudikZoneBlazor.Components.Account; using LudikZoneBlazor.Data; +using Npgsql; var builder = WebApplication.CreateBuilder(args); @@ -27,11 +28,20 @@ builder.Services.AddAuthentication(options => }) .AddIdentityCookies(); -var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); +#region Base de données +NpgsqlConnectionStringBuilder conStrBuilder = new NpgsqlConnectionStringBuilder(builder.Configuration.GetConnectionString("DefaultConnection")); +conStrBuilder.Host = string.IsNullOrEmpty(builder.Configuration["DB_HOST"]) ? conStrBuilder.Host : builder.Configuration["DB_HOST"]; +conStrBuilder.Username = string.IsNullOrEmpty(builder.Configuration["DB_USER"]) ? conStrBuilder.Username : builder.Configuration["DB_USER"]; +conStrBuilder.Database = string.IsNullOrEmpty(builder.Configuration["DB_DATABASE"]) ? conStrBuilder.Database : builder.Configuration["DB_DATABASE"]; +conStrBuilder.Port = int.TryParse(builder.Configuration["DB_PORT"], out int tempVal) ? tempVal : conStrBuilder.Port; +conStrBuilder.Password = builder.Configuration["DB_PASSWORD"]; + builder.Services.AddDbContext(options => - options.UseSqlite(connectionString)); + options.UseNpgsql(conStrBuilder.ToString())); builder.Services.AddDatabaseDeveloperPageExceptionFilter(); +#endregion + builder.Services.AddIdentityCore(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores() .AddSignInManager() diff --git a/src/LudikZoneBlazor/appsettings.Development.json b/src/LudikZoneBlazor/appsettings.Development.json index 0c208ae..2d9a7c2 100644 --- a/src/LudikZoneBlazor/appsettings.Development.json +++ b/src/LudikZoneBlazor/appsettings.Development.json @@ -1,8 +1,16 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "DefaultConnection": "host=localhost;username=admin;database=ludikZone;Pooling=false;Timeout=300;CommandTimeout=300;Port=5432;" + }, + "DB_HOST": "localhost", + "DB_PORT": 5432, + "DB_USER": "admin", + "DB_PASSWORD": "admin", + "DB_DATABASE": "ludikZone" +} \ No newline at end of file