mirror of https://github.com/abpframework/eventhub
15 changed files with 3023 additions and 72 deletions
@ -0,0 +1,34 @@ |
|||
using System.IO; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Payment; |
|||
|
|||
namespace EventHub.EntityFrameworkCore.Payment |
|||
{ |
|||
/* This class is needed for EF Core console commands |
|||
* (like Add-Migration and Update-Database commands) */ |
|||
public class EventHubPaymentDbContextFactory : IDesignTimeDbContextFactory<EventHubPaymentDbContext> |
|||
{ |
|||
public EventHubPaymentDbContext CreateDbContext(string[] args) |
|||
{ |
|||
EventHubEfCoreEntityExtensionMappings.Configure(); |
|||
|
|||
var configuration = BuildConfiguration(); |
|||
|
|||
var builder = new DbContextOptionsBuilder<EventHubPaymentDbContext>() |
|||
.UseSqlServer(configuration.GetConnectionString(PaymentDbProperties.ConnectionStringName)); |
|||
|
|||
return new EventHubPaymentDbContext(builder.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../EventHub.DbMigrator/")) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Payment; |
|||
using Payment.EntityFrameworkCore; |
|||
using Payment.PaymentRequests; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace EventHub.EntityFrameworkCore.Payment |
|||
{ |
|||
[ConnectionStringName(PaymentDbProperties.ConnectionStringName)] |
|||
public class EventHubPaymentDbContext : AbpDbContext<EventHubPaymentDbContext>, IPaymentDbContext |
|||
{ |
|||
public DbSet<PaymentRequest> PaymentRequests { get; set; } |
|||
|
|||
public EventHubPaymentDbContext( |
|||
DbContextOptions<EventHubPaymentDbContext> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
modelBuilder.ConfigurePayment(); |
|||
} |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EventHub.Migrations |
|||
{ |
|||
public partial class Remove_Payment_From_Main_Database : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "PayPaymentRequests"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "PayPaymentRequests", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
Currency = table.Column<string>(type: "text", nullable: true), |
|||
CustomerId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true), |
|||
FailReason = table.Column<string>(type: "text", nullable: true), |
|||
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false), |
|||
Price = table.Column<decimal>(type: "numeric", nullable: false), |
|||
ProductId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true), |
|||
ProductName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false), |
|||
State = table.Column<byte>(type: "smallint", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_PayPaymentRequests", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_PayPaymentRequests_CustomerId", |
|||
table: "PayPaymentRequests", |
|||
column: "CustomerId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_PayPaymentRequests_State", |
|||
table: "PayPaymentRequests", |
|||
column: "State"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using EventHub.EntityFrameworkCore.Payment; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EventHub.MigrationsPayment |
|||
{ |
|||
[DbContext(typeof(EventHubPaymentDbContext))] |
|||
[Migration("20211120105746_Initial_Payment_Database")] |
|||
partial class Initial_Payment_Database |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "6.0.0") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128); |
|||
|
|||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); |
|||
|
|||
modelBuilder.Entity("Payment.PaymentRequests.PaymentRequest", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("nvarchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime2") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uniqueidentifier") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("Currency") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("CustomerId") |
|||
.HasMaxLength(100) |
|||
.HasColumnType("nvarchar(100)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("FailReason") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bit") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<decimal>("Price") |
|||
.HasColumnType("decimal(18,2)"); |
|||
|
|||
b.Property<string>("ProductId") |
|||
.HasMaxLength(100) |
|||
.HasColumnType("nvarchar(100)"); |
|||
|
|||
b.Property<string>("ProductName") |
|||
.IsRequired() |
|||
.HasMaxLength(200) |
|||
.HasColumnType("nvarchar(200)"); |
|||
|
|||
b.Property<byte>("State") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("CustomerId"); |
|||
|
|||
b.HasIndex("State"); |
|||
|
|||
b.ToTable("PayPaymentRequests", (string)null); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EventHub.MigrationsPayment |
|||
{ |
|||
public partial class Initial_Payment_Database : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "PayPaymentRequests", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
|||
CustomerId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
ProductId = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true), |
|||
ProductName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false), |
|||
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false), |
|||
Currency = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
State = table.Column<byte>(type: "tinyint", nullable: false), |
|||
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
|||
FailReason = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true), |
|||
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_PayPaymentRequests", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_PayPaymentRequests_CustomerId", |
|||
table: "PayPaymentRequests", |
|||
column: "CustomerId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_PayPaymentRequests_State", |
|||
table: "PayPaymentRequests", |
|||
column: "State"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "PayPaymentRequests"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using EventHub.EntityFrameworkCore.Payment; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Metadata; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EventHub.MigrationsPayment |
|||
{ |
|||
[DbContext(typeof(EventHubPaymentDbContext))] |
|||
partial class EventHubPaymentDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) |
|||
.HasAnnotation("ProductVersion", "6.0.0") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 128); |
|||
|
|||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); |
|||
|
|||
modelBuilder.Entity("Payment.PaymentRequests.PaymentRequest", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uniqueidentifier"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("nvarchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime2") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("uniqueidentifier") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<string>("Currency") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<string>("CustomerId") |
|||
.HasMaxLength(100) |
|||
.HasColumnType("nvarchar(100)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("nvarchar(max)") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("FailReason") |
|||
.HasColumnType("nvarchar(max)"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("bit") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<decimal>("Price") |
|||
.HasColumnType("decimal(18,2)"); |
|||
|
|||
b.Property<string>("ProductId") |
|||
.HasMaxLength(100) |
|||
.HasColumnType("nvarchar(100)"); |
|||
|
|||
b.Property<string>("ProductName") |
|||
.IsRequired() |
|||
.HasMaxLength(200) |
|||
.HasColumnType("nvarchar(200)"); |
|||
|
|||
b.Property<byte>("State") |
|||
.HasColumnType("tinyint"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("CustomerId"); |
|||
|
|||
b.HasIndex("State"); |
|||
|
|||
b.ToTable("PayPaymentRequests", (string)null); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue