From 42dba1b6c1e1aadd31117a79897dc126b82123c1 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 26 Mar 2023 21:48:25 +0100 Subject: [PATCH] a migration --- src/Yavsc.Abstract/Messaging/Notification.cs | 11 +- src/Yavsc.Server/Models/ApplicationUser.cs | 13 +- .../Billing/NominativeServiceCommand.cs | 5 +- src/Yavsc.Server/Models/Blog/BlogPost.cs | 5 +- src/Yavsc.Server/Models/Workflow/Activity.cs | 4 +- src/Yavsc/Migrations/20230326173049_net7.cs | 142 +++++++++--------- src/Yavsc/Models/ApplicationDbContext.cs | 1 + 7 files changed, 94 insertions(+), 87 deletions(-) diff --git a/src/Yavsc.Abstract/Messaging/Notification.cs b/src/Yavsc.Abstract/Messaging/Notification.cs index 880632d2..2fbcb852 100644 --- a/src/Yavsc.Abstract/Messaging/Notification.cs +++ b/src/Yavsc.Abstract/Messaging/Notification.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -15,35 +16,42 @@ namespace Yavsc.Models.Messaging /// The title. /// [Required, Display(Name = "Titre")] + [StringLength(1024)] public string title { get; set; } /// /// The body. /// + [StringLength(512)] [Required, Display(Name = "Corps")] public string body { get; set; } /// /// The icon. /// + [StringLength(512)] [Display(Name = "Icône")] public string icon { get; set; } /// /// The sound. /// + [StringLength(512)] [Display(Name = "Son")] public string sound { get; set; } /// /// The tag. /// + [StringLength(512)] [Display(Name = "Tag")] public string tag { get; set; } /// /// The color. /// + [StringLength(512)] [Display(Name = "Couleur")] - public string color { get; set; } + public string color { get; set; } /// /// The click action. /// + [StringLength(512)] [Required, Display(Name = "Label du click")] public string click_action { get; set; } @@ -54,6 +62,7 @@ namespace Yavsc.Models.Messaging /// administration : for admins ... /// /// + [StringLength(512)] public string Target { get; set; } public Notification() diff --git a/src/Yavsc.Server/Models/ApplicationUser.cs b/src/Yavsc.Server/Models/ApplicationUser.cs index 1cf52f35..f0196af0 100644 --- a/src/Yavsc.Server/Models/ApplicationUser.cs +++ b/src/Yavsc.Server/Models/ApplicationUser.cs @@ -1,19 +1,14 @@ - -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; using Microsoft.AspNetCore.Identity; using Yavsc.Models.Relationship; - using Yavsc.Models.Relationship; - using Yavsc.Models.Identity; - using Yavsc.Models.Chat; - using Yavsc.Models.Bank; - using Yavsc.Models.Access; +using Yavsc.Models.Identity; +using Yavsc.Models.Chat; +using Yavsc.Models.Bank; +using Yavsc.Models.Access; namespace Yavsc.Models { - public class ApplicationUser : IdentityUser, IBaseTrackedEntity { diff --git a/src/Yavsc.Server/Models/Billing/NominativeServiceCommand.cs b/src/Yavsc.Server/Models/Billing/NominativeServiceCommand.cs index 3aed8719..c0c167ef 100644 --- a/src/Yavsc.Server/Models/Billing/NominativeServiceCommand.cs +++ b/src/Yavsc.Server/Models/Billing/NominativeServiceCommand.cs @@ -97,10 +97,11 @@ namespace Yavsc.Models.Billing return $"facture-{bcode}-{Id}{ack}"; } - [Display(Name = "PaymentId")] + [ForeignKey("Regularisation")] + public string PaymentId { get; set; } - [ForeignKey("PaymentId"), Display(Name = "Acquittement de la facture")] + [Display(Name = "Acquittement de la facture")] public virtual PayPalPayment Regularisation { get; set; } } diff --git a/src/Yavsc.Server/Models/Blog/BlogPost.cs b/src/Yavsc.Server/Models/Blog/BlogPost.cs index c956a669..423dc1e3 100644 --- a/src/Yavsc.Server/Models/Blog/BlogPost.cs +++ b/src/Yavsc.Server/Models/Blog/BlogPost.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using Yavsc.Abstract.Identity.Security; using Yavsc.Attributes.Validation; @@ -34,11 +35,11 @@ namespace Yavsc.Models.Blog public string Title { get; set; } [Display(Name="Identifiant de l'auteur")] + [ForeignKey("Author")] public string AuthorId { get; set; } [Display(Name="Auteur")] - [ForeignKey("AuthorId"),JsonIgnore] - public ApplicationUser Author { set; get; } + public virtual ApplicationUser Author { set; get; } [Display(Name="Visible")] public bool Visible { get; set; } diff --git a/src/Yavsc.Server/Models/Workflow/Activity.cs b/src/Yavsc.Server/Models/Workflow/Activity.cs index 0bb20335..6106012b 100644 --- a/src/Yavsc.Server/Models/Workflow/Activity.cs +++ b/src/Yavsc.Server/Models/Workflow/Activity.cs @@ -27,10 +27,10 @@ namespace Yavsc.Models.Workflow [YaStringLength(512)] [Display(Name = "Code du parent")] + [ForeignKey("Parent")] public string ParentCode { get; set; } - [ForeignKey("ParentCode"), JsonIgnore] - [Display(Name = "Activité parent")] + [Display(Name = "Activité parent"), JsonIgnore] public virtual Activity Parent { get; set; } [InverseProperty("Parent"), JsonIgnore] diff --git a/src/Yavsc/Migrations/20230326173049_net7.cs b/src/Yavsc/Migrations/20230326173049_net7.cs index 8d5929ce..00e07395 100644 --- a/src/Yavsc/Migrations/20230326173049_net7.cs +++ b/src/Yavsc/Migrations/20230326173049_net7.cs @@ -36,25 +36,30 @@ namespace Yavsc.Migrations name: "FK_BlogTag_Tag_TagId", table: "BlogTag"); - migrationBuilder.DropPrimaryKey( - name: "PK_Blog", - table: "BlogPost"); + + migrationBuilder.DropForeignKey( name: "FK_Activity_Activity_ParentCode", table: "Activity"); - - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( + name: "FK_AspNetUsers_Location_PostalAddressId", + table: "AspNetUsers"); + /* migrationBuilder.DropPrimaryKey( + name: "PK_Blog", + table: "BlogPost"); + + migrationBuilder.DropForeignKey( name: "FK_AccountBalance_AspNetUsers_UserId", - table: "AccountBalance"); */ + table: "AccountBalance"); */ - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( name: "FK_Announce_AspNetUsers_OwnerId", - table: "Announce"); + table: "Announce"); migrationBuilder.DropForeignKey( name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", - table: "AspNetRoleClaims"); + table: "AspNetRoleClaims"); migrationBuilder.DropForeignKey( name: "FK_AspNetUserClaims_AspNetUsers_UserId", @@ -76,45 +81,39 @@ namespace Yavsc.Migrations name: "FK_AspNetUsers_BankIdentity_BankInfoId", table: "AspNetUsers"); - migrationBuilder.DropForeignKey( - name: "FK_AspNetUsers_Location_PostalAddressId", - table: "AspNetUsers"); + migrationBuilder.DropForeignKey( name: "FK_Ban_AspNetUsers_TargetId", - table: "Ban");*/ - - migrationBuilder.DropForeignKey( - name: "FK_ApplicationUser_BankIdentity_BankInfoId", - table: "AspNetUsers"); - migrationBuilder.DropForeignKey( - name: "FK_ApplicationUser_Location_PostalAddressId", - table: "AspNetUsers"); - migrationBuilder.DropForeignKey( - name: "FK_Ban_ApplicationUser_TargetId", table: "Ban"); - migrationBuilder.DropForeignKey( name: "FK_BalanceImpact_AccountBalance_BalanceId", table: "BalanceImpact"); -/* migrationBuilder.DropForeignKey( name: "FK_BlackListed_AspNetUsers_OwnerId", table: "BlackListed"); - migrationBuilder.DropForeignKey( name: "FK_BlackListed_AspNetUsers_UserId", table: "BlackListed"); - migrationBuilder.DropForeignKey( name: "FK_BlogPost_AspNetUsers_AuthorId", - table: "BlogPost");*/ + table: "BlogPost"); + + /* migrationBuilder.DropForeignKey( + name: "FK_ApplicationUser_BankIdentity_BankInfoId", + table: "AspNetUsers"); + migrationBuilder.DropForeignKey( + name: "FK_ApplicationUser_Location_PostalAddressId", + table: "AspNetUsers"); + migrationBuilder.DropForeignKey( + name: "FK_Ban_ApplicationUser_TargetId", + table: "Ban"); + +*/ - -/* migrationBuilder.DropForeignKey( name: "FK_BlogTrad_AspNetUsers_TraducerId", - table: "BlogTrad");*/ + table: "BlogTrad"); migrationBuilder.DropForeignKey( name: "FK_BrusherProfile_PerformerProfile_UserId", @@ -126,27 +125,25 @@ namespace Yavsc.Migrations migrationBuilder.DropForeignKey( name: "FK_Bug_Feature_FeatureId", - table: "Bug"); -/* + table: "Bug"); migrationBuilder.DropForeignKey( name: "FK_ChatConnection_AspNetUsers_ApplicationUserId", table: "ChatConnection"); - migrationBuilder.DropForeignKey( name: "FK_ChatRoom_AspNetUsers_OwnerId", table: "ChatRoom"); migrationBuilder.DropForeignKey( name: "FK_ChatRoomAccess_AspNetUsers_UserId", - table: "ChatRoomAccess");*/ + table: "ChatRoomAccess"); migrationBuilder.DropForeignKey( name: "FK_ChatRoomAccess_ChatRoom_ChannelName", table: "ChatRoomAccess"); - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( name: "FK_CircleMember_AspNetUsers_MemberId", - table: "CircleMember"); */ + table: "CircleMember"); migrationBuilder.DropForeignKey( name: "FK_CircleMember_Circle_CircleId", @@ -163,39 +160,39 @@ namespace Yavsc.Migrations migrationBuilder.DropForeignKey( name: "FK_CommandLine_Estimate_EstimateId", table: "CommandLine"); -/* + migrationBuilder.DropForeignKey( name: "FK_Comment_AspNetUsers_AuthorId", - table: "Comment");*/ + table: "Comment"); migrationBuilder.DropForeignKey( name: "FK_Contact_PostalAddress_AddressId", table: "Contact"); -/* + migrationBuilder.DropForeignKey( name: "FK_CoWorking_AspNetUsers_WorkingForId", - table: "CoWorking");*/ + table: "CoWorking"); migrationBuilder.DropForeignKey( name: "FK_CoWorking_PerformerProfile_PerformerId", table: "CoWorking"); - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( name: "FK_DeviceDeclaration_AspNetUsers_DeviceOwnerId", table: "DeviceDeclaration"); migrationBuilder.DropForeignKey( name: "FK_DimissClicked_AspNetUsers_UserId", - table: "DimissClicked");*/ + table: "DimissClicked"); migrationBuilder.DropForeignKey( name: "FK_DimissClicked_Notification_NotificationId", table: "DimissClicked"); -/* + migrationBuilder.DropForeignKey( name: "FK_Estimate_AspNetUsers_ClientId", - table: "Estimate");*/ + table: "Estimate"); migrationBuilder.DropForeignKey( name: "FK_Estimate_PerformerProfile_OwnerId", @@ -205,17 +202,17 @@ namespace Yavsc.Migrations name: "FK_Estimate_RdvQuery_CommandId", table: "Estimate"); - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( name: "FK_GitRepositoryReference_AspNetUsers_OwnerId", - table: "GitRepositoryReference"); */ + table: "GitRepositoryReference"); migrationBuilder.DropForeignKey( name: "FK_HairCutQuery_Activity_ActivityCode", table: "HairCutQuery"); - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( name: "FK_HairCutQuery_AspNetUsers_ClientId", - table: "HairCutQuery"); */ + table: "HairCutQuery"); migrationBuilder.DropForeignKey( name: "FK_HairCutQuery_BrusherProfile_SelectedProfileUserId", @@ -229,10 +226,10 @@ namespace Yavsc.Migrations name: "FK_HairCutQuery_Location_LocationId", table: "HairCutQuery"); -/* + migrationBuilder.DropForeignKey( name: "FK_HairCutQuery_PayPalPayment_PaymentId", - table: "HairCutQuery"); */ + table: "HairCutQuery"); migrationBuilder.DropForeignKey( name: "FK_HairCutQuery_PerformerProfile_PerformerId", @@ -242,17 +239,17 @@ namespace Yavsc.Migrations name: "FK_HairMultiCutQuery_Activity_ActivityCode", table: "HairMultiCutQuery"); - /* migrationBuilder.DropForeignKey( + migrationBuilder.DropForeignKey( name: "FK_HairMultiCutQuery_AspNetUsers_ClientId", - table: "HairMultiCutQuery"); */ + table: "HairMultiCutQuery"); migrationBuilder.DropForeignKey( name: "FK_HairMultiCutQuery_Location_LocationId", table: "HairMultiCutQuery"); -/* + migrationBuilder.DropForeignKey( name: "FK_HairMultiCutQuery_PayPalPayment_PaymentId", - table: "HairMultiCutQuery"); */ + table: "HairMultiCutQuery"); migrationBuilder.DropForeignKey( name: "FK_HairMultiCutQuery_PerformerProfile_PerformerId", @@ -293,7 +290,7 @@ namespace Yavsc.Migrations migrationBuilder.DropForeignKey( name: "FK_InstrumentRating_PerformerProfile_OwnerId", table: "InstrumentRating"); -/* + migrationBuilder.DropForeignKey( name: "FK_LiveFlow_AspNetUsers_OwnerId", table: "LiveFlow"); @@ -304,7 +301,7 @@ namespace Yavsc.Migrations migrationBuilder.DropForeignKey( name: "FK_PerformerProfile_AspNetUsers_PerformerId", - table: "PerformerProfile");*/ + table: "PerformerProfile"); migrationBuilder.DropForeignKey( name: "FK_PerformerProfile_Location_OrganizationAddressId", @@ -313,10 +310,10 @@ namespace Yavsc.Migrations migrationBuilder.DropForeignKey( name: "FK_Project_Activity_ActivityCode", table: "Project"); -/* + migrationBuilder.DropForeignKey( name: "FK_Project_AspNetUsers_ClientId", - table: "Project"); */ + table: "Project"); migrationBuilder.DropForeignKey( name: "FK_Project_GitRepositoryReference_GitId", @@ -337,26 +334,26 @@ namespace Yavsc.Migrations migrationBuilder.DropForeignKey( name: "FK_RdvQuery_Activity_ActivityCode", table: "RdvQuery"); -/* + migrationBuilder.DropForeignKey( name: "FK_RdvQuery_AspNetUsers_ClientId", - table: "RdvQuery"); */ + table: "RdvQuery"); migrationBuilder.DropForeignKey( name: "FK_RdvQuery_Location_LocationId", table: "RdvQuery"); -/* + migrationBuilder.DropForeignKey( name: "FK_RdvQuery_PayPalPayment_PaymentId", - table: "RdvQuery"); */ + table: "RdvQuery"); migrationBuilder.DropForeignKey( name: "FK_RdvQuery_PerformerProfile_PerformerId", table: "RdvQuery"); -/* + migrationBuilder.DropForeignKey( name: "FK_Schedule_AspNetUsers_OwnerId", - table: "Schedule"); */ + table: "Schedule"); migrationBuilder.DropForeignKey( name: "FK_ScheduledEvent_Period_PeriodStart_PeriodEnd", @@ -2438,7 +2435,7 @@ namespace Yavsc.Migrations name: "UserModified", table: "Blogspot", type: "text", - nullable: false, + nullable: true, defaultValue: "", oldClrType: typeof(string), oldType: "text", @@ -2448,7 +2445,7 @@ namespace Yavsc.Migrations name: "UserCreated", table: "Blogspot", type: "text", - nullable: false, + nullable: true, defaultValue: "", oldClrType: typeof(string), oldType: "text", @@ -2458,7 +2455,7 @@ namespace Yavsc.Migrations name: "Title", table: "Blogspot", type: "text", - nullable: false, + nullable: true, defaultValue: "", oldClrType: typeof(string), oldType: "text", @@ -2468,7 +2465,7 @@ namespace Yavsc.Migrations name: "Photo", table: "Blogspot", type: "text", - nullable: false, + nullable: true, defaultValue: "", oldClrType: typeof(string), oldType: "text", @@ -2478,7 +2475,7 @@ namespace Yavsc.Migrations name: "Lang", table: "Blogspot", type: "text", - nullable: false, + nullable: true, defaultValue: "", oldClrType: typeof(string), oldType: "text", @@ -2499,7 +2496,7 @@ namespace Yavsc.Migrations table: "Blogspot", type: "text", nullable: true, - defaultValue: "", + defaultValue: null, oldClrType: typeof(string), oldType: "text", oldNullable: true); @@ -2681,7 +2678,10 @@ namespace Yavsc.Migrations name: "PK_CircleMembers", table: "CircleMembers", columns: new[] { "MemberId", "CircleId" }); - + migrationBuilder.DropPrimaryKey( + "PK_BlogPost","Blogspot" + ); + migrationBuilder.AddPrimaryKey( name: "PK_Blogspot", table: "Blogspot", diff --git a/src/Yavsc/Models/ApplicationDbContext.cs b/src/Yavsc/Models/ApplicationDbContext.cs index 5f960398..8e7cded8 100644 --- a/src/Yavsc/Models/ApplicationDbContext.cs +++ b/src/Yavsc/Models/ApplicationDbContext.cs @@ -77,6 +77,7 @@ namespace Yavsc.Models } builder.Entity().Property(a=>a.ParentCode).IsRequired(false); + builder.Entity().HasOne(p => p.Author).WithMany(a => a.Posts); } // this is not a failback procedure.