From efdd916e6fd1dc84fdf6cdc923bc23d4f559a1be Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sat, 26 Mar 2022 11:10:13 +0800 Subject: [PATCH] feat(webhooks): added ef migrations --- ...Add-Module-WebHooks-Management.Designer.cs | 166 ++++++++++++++++++ ...26030345_Add-Module-WebHooks-Management.cs | 104 +++++++++++ ...agementMigrationsDbContextModelSnapshot.cs | 164 +++++++++++++++++ .../Properties/launchSettings.json | 2 +- .../WebhooksManagementHttpApiHostModule.cs | 2 + .../appsettings.Development.json | 42 ++--- 6 files changed, 450 insertions(+), 30 deletions(-) create mode 100644 aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.Designer.cs create mode 100644 aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.cs create mode 100644 aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.Designer.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.Designer.cs new file mode 100644 index 000000000..bdf69d7be --- /dev/null +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.Designer.cs @@ -0,0 +1,166 @@ +// +using System; +using LY.MicroService.WebhooksManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.WebhooksManagement.Migrations +{ + [DbContext(typeof(WebhooksManagementMigrationsDbContext))] + [Migration("20220326030345_Add-Module-WebHooks-Management")] + partial class AddModuleWebHooksManagement + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("Data") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Data"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("WebhookName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("WebhookName"); + + b.HasKey("Id"); + + b.ToTable("WebhooksManagement_WebhookEvents", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("Response") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Response"); + + b.Property("ResponseStatusCode") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("WebhookEventId") + .HasColumnType("char(36)"); + + b.Property("WebhookSubscriptionId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("WebhookEventId") + .IsUnique(); + + b.ToTable("WebhooksManagement_WebhookSendAttempts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Headers") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Headers"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Secret") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("Secret"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookUri") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("WebhookUri"); + + b.Property("Webhooks") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Webhooks"); + + b.HasKey("Id"); + + b.ToTable("WebhooksManagement_WebhookSubscriptions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.HasOne("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", "WebhookEvent") + .WithOne() + .HasForeignKey("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", "WebhookEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WebhookEvent"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.cs new file mode 100644 index 000000000..ca7fd42f9 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/20220326030345_Add-Module-WebHooks-Management.cs @@ -0,0 +1,104 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LY.MicroService.WebhooksManagement.Migrations +{ + public partial class AddModuleWebHooksManagement : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterDatabase() + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "WebhooksManagement_WebhookEvents", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + WebhookName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Data = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + DeletionTime = table.Column(type: "datetime(6)", nullable: true), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false, defaultValue: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WebhooksManagement_WebhookEvents", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "WebhooksManagement_WebhookSubscriptions", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + WebhookUri = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Secret = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsActive = table.Column(type: "tinyint(1)", nullable: false), + Webhooks = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Headers = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + CreatorId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") + }, + constraints: table => + { + table.PrimaryKey("PK_WebhooksManagement_WebhookSubscriptions", x => x.Id); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "WebhooksManagement_WebhookSendAttempts", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + TenantId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), + WebhookEventId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + WebhookSubscriptionId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + Response = table.Column(type: "longtext", maxLength: 2147483647, nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + ResponseStatusCode = table.Column(type: "int", nullable: true), + CreationTime = table.Column(type: "datetime(6)", nullable: false), + LastModificationTime = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WebhooksManagement_WebhookSendAttempts", x => x.Id); + table.ForeignKey( + name: "FK_WebhooksManagement_WebhookSendAttempts_WebhooksManagement_We~", + column: x => x.WebhookEventId, + principalTable: "WebhooksManagement_WebhookEvents", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_WebhooksManagement_WebhookSendAttempts_WebhookEventId", + table: "WebhooksManagement_WebhookSendAttempts", + column: "WebhookEventId", + unique: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "WebhooksManagement_WebhookSendAttempts"); + + migrationBuilder.DropTable( + name: "WebhooksManagement_WebhookSubscriptions"); + + migrationBuilder.DropTable( + name: "WebhooksManagement_WebhookEvents"); + } + } +} diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs new file mode 100644 index 000000000..966262d85 --- /dev/null +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Migrations/WebhooksManagementMigrationsDbContextModelSnapshot.cs @@ -0,0 +1,164 @@ +// +using System; +using LY.MicroService.WebhooksManagement.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace LY.MicroService.WebhooksManagement.Migrations +{ + [DbContext(typeof(WebhooksManagementMigrationsDbContext))] + partial class WebhooksManagementMigrationsDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) + .HasAnnotation("ProductVersion", "6.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("Data") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Data"); + + b.Property("DeletionTime") + .HasColumnType("datetime(6)") + .HasColumnName("DeletionTime"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("tinyint(1)") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("WebhookName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)") + .HasColumnName("WebhookName"); + + b.HasKey("Id"); + + b.ToTable("WebhooksManagement_WebhookEvents", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("LastModificationTime") + .HasColumnType("datetime(6)") + .HasColumnName("LastModificationTime"); + + b.Property("Response") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Response"); + + b.Property("ResponseStatusCode") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("char(36)") + .HasColumnName("TenantId"); + + b.Property("WebhookEventId") + .HasColumnType("char(36)"); + + b.Property("WebhookSubscriptionId") + .HasColumnType("char(36)"); + + b.HasKey("Id"); + + b.HasIndex("WebhookEventId") + .IsUnique(); + + b.ToTable("WebhooksManagement_WebhookSendAttempts", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("char(36)"); + + b.Property("CreationTime") + .HasColumnType("datetime(6)") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("char(36)") + .HasColumnName("CreatorId"); + + b.Property("Headers") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Headers"); + + b.Property("IsActive") + .HasColumnType("tinyint(1)"); + + b.Property("Secret") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("varchar(128)") + .HasColumnName("Secret"); + + b.Property("TenantId") + .HasColumnType("char(36)"); + + b.Property("WebhookUri") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("varchar(255)") + .HasColumnName("WebhookUri"); + + b.Property("Webhooks") + .HasMaxLength(2147483647) + .HasColumnType("longtext") + .HasColumnName("Webhooks"); + + b.HasKey("Id"); + + b.ToTable("WebhooksManagement_WebhookSubscriptions", (string)null); + }); + + modelBuilder.Entity("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", b => + { + b.HasOne("LINGYUN.Abp.WebhooksManagement.WebhookEventRecord", "WebhookEvent") + .WithOne() + .HasForeignKey("LINGYUN.Abp.WebhooksManagement.WebhookSendRecord", "WebhookEventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WebhookEvent"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json index c269dc698..7e93c505e 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/Properties/launchSettings.json @@ -8,7 +8,7 @@ } }, "profiles": { - "LY..WebhooksManagement.HttpApi.Host": { + "LY.MicroService.WebhooksManagement.HttpApi.Host": { "commandName": "Project", "launchBrowser": false, "environmentVariables": { diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs index 5d89fbec0..ec561d610 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs @@ -85,6 +85,8 @@ public partial class WebhooksManagementHttpApiHostModule : AbpModule ConfigureDistributedLock(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); + + // context.Services.AddAlwaysAllowAuthorization(); } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json index 7c28c17fe..4a816c0c1 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.Development.json @@ -1,22 +1,22 @@ { "AgileConfig": { "env": "DEV", - "appId": "LY.MicroService.WebhooksManagement", + "appId": "LINGYUN.Abp.WebhooksManagement", "secret": "1q2w3E*", "nodes": "http://127.0.0.1:15000", - "name": "LY.MicroService.WebhooksManagement", - "tag": "LY.MicroService.WebhooksManagement" + "name": "LINGYUN.Abp.WebhooksManagement", + "tag": "LINGYUN.Abp.WebhooksManagement" }, "App": { "TrackingEntitiesChanged": true }, "ConnectionStrings": { - "Default": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456", - "WebhooksManagement": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456", - "AbpSaas": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456", - "AbpFeatureManagement": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456", - "AbpPermissionManagement": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456", - "AbpSettingManagement": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456" + "Default": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "WebhooksManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "AbpFeatureManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "AbpPermissionManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456", + "AbpSettingManagement": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" }, "DistributedLock": { "Redis": { @@ -48,30 +48,14 @@ "FailedRetryCount": 10 }, "MySql": { - "TableNamePrefix": "WebhooksManagement_cap", - "ConnectionString": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456" - }, - "SqlServer": { - "TableNamePrefix": "WebhooksManagement_cap", - "ConnectionString": "Server=127.0.0.1;Database=WebhooksManagement;User Id=root;Password=123456" - }, - "Sqlite": { - "TableNamePrefix": "WebhooksManagement_cap", - "ConnectionString": "Data Source=./cap.db" - }, - "Oracle": { - "TableNamePrefix": "WebhooksManagement_cap", - "ConnectionString": "Data Source=WebhooksManagement;Integrated Security=yes;" - }, - "PostgreSql": { - "TableNamePrefix": "WebhooksManagement_cap", - "ConnectionString": "Host=localhost;Port=5432;Database=WebhooksManagement;User ID=root;Password=123456;" + "TableNamePrefix": "wkm", + "ConnectionString": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" }, "RabbitMQ": { "HostName": "127.0.0.1", "Port": 5672, - "UserName": "admin", - "Password": "123456", + "UserName": "guest", + "Password": "guest", "ExchangeName": "LINGYUN.Abp.Application", "VirtualHost": "/" }