数据库对象命名约定
This commit is contained in:
parent
2036f447d5
commit
a027f6fc04
@ -6,5 +6,7 @@ namespace HelloShop.IdentityService.Constants
|
|||||||
public class DbConstants
|
public class DbConstants
|
||||||
{
|
{
|
||||||
public const string ConnectionStringName = "IdentityDatabase";
|
public const string ConnectionStringName = "IdentityDatabase";
|
||||||
|
|
||||||
|
public const string MigrationsHistoryTableName = "migrations_history";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||||
|
@ -10,8 +10,6 @@ public class PermissionGrantedEntityTypeConfiguration : IEntityTypeConfiguration
|
|||||||
{
|
{
|
||||||
public void Configure(Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<PermissionGranted> builder)
|
public void Configure(Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<PermissionGranted> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("PermissionGranted");
|
|
||||||
|
|
||||||
builder.Property(x => x.Id);
|
builder.Property(x => x.Id);
|
||||||
builder.Property(x => x.PermissionName).HasMaxLength(64);
|
builder.Property(x => x.PermissionName).HasMaxLength(64);
|
||||||
builder.Property(x => x.ResourceType).HasMaxLength(16);
|
builder.Property(x => x.ResourceType).HasMaxLength(16);
|
||||||
|
@ -11,7 +11,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<IdentityRoleClaim<int>> builder)
|
public void Configure(EntityTypeBuilder<IdentityRoleClaim<int>> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("RoleClaims");
|
builder.ToTable("role_claim");
|
||||||
|
|
||||||
builder.Property(rc => rc.ClaimType).HasMaxLength(128);
|
builder.Property(rc => rc.ClaimType).HasMaxLength(128);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Role> builder)
|
public void Configure(EntityTypeBuilder<Role> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("Roles");
|
builder.ToTable("role");
|
||||||
|
|
||||||
builder.Property(r => r.Id).HasColumnOrder(1);
|
builder.Property(r => r.Id).HasColumnOrder(1);
|
||||||
builder.Property(r => r.Name).HasMaxLength(16).HasColumnOrder(2);
|
builder.Property(r => r.Name).HasMaxLength(16).HasColumnOrder(2);
|
||||||
|
@ -11,7 +11,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<IdentityUserClaim<int>> builder)
|
public void Configure(EntityTypeBuilder<IdentityUserClaim<int>> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("UserClaims");
|
builder.ToTable("user_claim");
|
||||||
|
|
||||||
builder.Property(uc => uc.ClaimType).HasMaxLength(128);
|
builder.Property(uc => uc.ClaimType).HasMaxLength(128);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<User> builder)
|
public void Configure(EntityTypeBuilder<User> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("Users");
|
builder.ToTable("user");
|
||||||
|
|
||||||
builder.Property(u => u.Id).HasColumnOrder(1);
|
builder.Property(u => u.Id).HasColumnOrder(1);
|
||||||
builder.Property(u => u.UserName).HasMaxLength(16).HasColumnOrder(2);
|
builder.Property(u => u.UserName).HasMaxLength(16).HasColumnOrder(2);
|
||||||
|
@ -11,7 +11,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<IdentityUserLogin<int>> builder)
|
public void Configure(EntityTypeBuilder<IdentityUserLogin<int>> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("UserLogins");
|
builder.ToTable("user_login");
|
||||||
|
|
||||||
builder.Property(ul => ul.LoginProvider).HasMaxLength(16);
|
builder.Property(ul => ul.LoginProvider).HasMaxLength(16);
|
||||||
builder.Property(ul => ul.ProviderDisplayName).HasMaxLength(16);
|
builder.Property(ul => ul.ProviderDisplayName).HasMaxLength(16);
|
||||||
|
@ -10,7 +10,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<IdentityUserRole<int>> builder)
|
public void Configure(Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<IdentityUserRole<int>> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("UserRoles");
|
builder.ToTable("user_role");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace HelloShop.IdentityService.Infrastructure.EntityConfigurations
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<IdentityUserToken<int>> builder)
|
public void Configure(EntityTypeBuilder<IdentityUserToken<int>> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("UserTokens");
|
builder.ToTable("user_token");
|
||||||
|
|
||||||
builder.Property(ut => ut.Name).HasMaxLength(16);
|
builder.Property(ut => ut.Name).HasMaxLength(16);
|
||||||
builder.Property(ut => ut.LoginProvider).HasMaxLength(16);
|
builder.Property(ut => ut.LoginProvider).HasMaxLength(16);
|
||||||
|
@ -13,8 +13,13 @@ namespace HelloShop.IdentityService.Infrastructure
|
|||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
base.OnConfiguring(optionsBuilder);
|
||||||
|
optionsBuilder.UseSnakeCaseNamingConvention();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,260 +0,0 @@
|
|||||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
|
||||||
// See the license file in the project root for more information.
|
|
||||||
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Roles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
NormalizedName = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
|
||||||
CreationTime = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Roles", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Users",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
UserName = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
NormalizedUserName = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
Email = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
||||||
NormalizedEmail = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
||||||
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
PasswordHash = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
|
|
||||||
SecurityStamp = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
||||||
ConcurrencyStamp = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
|
||||||
PhoneNumber = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
|
||||||
AccessFailedCount = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
CreationTime = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Users", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PermissionGranted",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
RoleId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
PermissionName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
||||||
ResourceType = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
ResourceId = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PermissionGranted", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PermissionGranted_Roles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "Roles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "RoleClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
RoleId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_RoleClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_RoleClaims_Roles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "Roles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserClaims",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ClaimType = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
|
||||||
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserClaims", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserClaims_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserLogins",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
LoginProvider = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
ProviderKey = table.Column<string>(type: "text", nullable: false),
|
|
||||||
ProviderDisplayName = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
|
||||||
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserLogins_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserRoles",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
RoleId = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserRoles_Roles_RoleId",
|
|
||||||
column: x => x.RoleId,
|
|
||||||
principalTable: "Roles",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserRoles_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "UserTokens",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
UserId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
LoginProvider = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
Name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
Value = table.Column<string>(type: "text", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_UserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_UserTokens_Users_UserId",
|
|
||||||
column: x => x.UserId,
|
|
||||||
principalTable: "Users",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PermissionGranted_RoleId_PermissionName_ResourceType_Resour~",
|
|
||||||
table: "PermissionGranted",
|
|
||||||
columns: new[] { "RoleId", "PermissionName", "ResourceType", "ResourceId" },
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_RoleClaims_RoleId",
|
|
||||||
table: "RoleClaims",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "RoleNameIndex",
|
|
||||||
table: "Roles",
|
|
||||||
column: "NormalizedName",
|
|
||||||
unique: true);
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserClaims_UserId",
|
|
||||||
table: "UserClaims",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserLogins_UserId",
|
|
||||||
table: "UserLogins",
|
|
||||||
column: "UserId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_UserRoles_RoleId",
|
|
||||||
table: "UserRoles",
|
|
||||||
column: "RoleId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "EmailIndex",
|
|
||||||
table: "Users",
|
|
||||||
column: "NormalizedEmail");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "UserNameIndex",
|
|
||||||
table: "Users",
|
|
||||||
column: "NormalizedUserName",
|
|
||||||
unique: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PermissionGranted");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "RoleClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserClaims");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserLogins");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserRoles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "UserTokens");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Roles");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Users");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,10 +9,10 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
namespace HelloShop.IdentityService.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(IdentityServiceDbContext))]
|
[DbContext(typeof(IdentityServiceDbContext))]
|
||||||
[Migration("20240403122821_InitialCreate")]
|
[Migration("20241123020852_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -20,7 +20,7 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.2")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -29,32 +29,39 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("PermissionName")
|
b.Property<string>("PermissionName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("permission_name");
|
||||||
|
|
||||||
b.Property<string>("ResourceId")
|
b.Property<string>("ResourceId")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)");
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("resource_id");
|
||||||
|
|
||||||
b.Property<string>("ResourceType")
|
b.Property<string>("ResourceType")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("resource_type");
|
||||||
|
|
||||||
b.Property<int>("RoleId")
|
b.Property<int>("RoleId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("role_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_permission_granted");
|
||||||
|
|
||||||
b.HasIndex("RoleId", "PermissionName", "ResourceType", "ResourceId")
|
b.HasIndex("RoleId", "PermissionName", "ResourceType", "ResourceId")
|
||||||
.IsUnique();
|
.IsUnique()
|
||||||
|
.HasDatabaseName("ix_permission_granted_role_id_permission_name_resource_type_re");
|
||||||
|
|
||||||
b.ToTable("PermissionGranted", (string)null);
|
b.ToTable("permission_granted", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.IdentityService.Entities.Role", b =>
|
modelBuilder.Entity("HelloShop.IdentityService.Entities.Role", b =>
|
||||||
@ -62,6 +69,7 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
.HasColumnOrder(1);
|
.HasColumnOrder(1);
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
@ -70,29 +78,34 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)")
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("concurrency_stamp")
|
||||||
.HasColumnOrder(4);
|
.HasColumnOrder(4);
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreationTime")
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time")
|
||||||
.HasColumnOrder(5);
|
.HasColumnOrder(5);
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("name")
|
||||||
.HasColumnOrder(2);
|
.HasColumnOrder(2);
|
||||||
|
|
||||||
b.Property<string>("NormalizedName")
|
b.Property<string>("NormalizedName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("normalized_name")
|
||||||
.HasColumnOrder(3);
|
.HasColumnOrder(3);
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_role");
|
||||||
|
|
||||||
b.HasIndex("NormalizedName")
|
b.HasIndex("NormalizedName")
|
||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasDatabaseName("RoleNameIndex");
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
b.ToTable("Roles", (string)null);
|
b.ToTable("role", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.IdentityService.Entities.User", b =>
|
modelBuilder.Entity("HelloShop.IdentityService.Entities.User", b =>
|
||||||
@ -100,80 +113,97 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
.HasColumnOrder(1);
|
.HasColumnOrder(1);
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("AccessFailedCount")
|
b.Property<int>("AccessFailedCount")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("access_failed_count")
|
||||||
.HasColumnOrder(15);
|
.HasColumnOrder(15);
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
b.Property<string>("ConcurrencyStamp")
|
||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)")
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("concurrency_stamp")
|
||||||
.HasColumnOrder(9);
|
.HasColumnOrder(9);
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreationTime")
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time")
|
||||||
.HasColumnOrder(16);
|
.HasColumnOrder(16);
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)")
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("email")
|
||||||
.HasColumnOrder(4);
|
.HasColumnOrder(4);
|
||||||
|
|
||||||
b.Property<bool>("EmailConfirmed")
|
b.Property<bool>("EmailConfirmed")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("email_confirmed")
|
||||||
.HasColumnOrder(6);
|
.HasColumnOrder(6);
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
b.Property<bool>("LockoutEnabled")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("lockout_enabled")
|
||||||
.HasColumnOrder(14);
|
.HasColumnOrder(14);
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("lockout_end")
|
||||||
.HasColumnOrder(13);
|
.HasColumnOrder(13);
|
||||||
|
|
||||||
b.Property<string>("NormalizedEmail")
|
b.Property<string>("NormalizedEmail")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)")
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("normalized_email")
|
||||||
.HasColumnOrder(5);
|
.HasColumnOrder(5);
|
||||||
|
|
||||||
b.Property<string>("NormalizedUserName")
|
b.Property<string>("NormalizedUserName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("normalized_user_name")
|
||||||
.HasColumnOrder(3);
|
.HasColumnOrder(3);
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
b.Property<string>("PasswordHash")
|
||||||
.HasMaxLength(512)
|
.HasMaxLength(512)
|
||||||
.HasColumnType("character varying(512)")
|
.HasColumnType("character varying(512)")
|
||||||
|
.HasColumnName("password_hash")
|
||||||
.HasColumnOrder(7);
|
.HasColumnOrder(7);
|
||||||
|
|
||||||
b.Property<string>("PhoneNumber")
|
b.Property<string>("PhoneNumber")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("phone_number")
|
||||||
.HasColumnOrder(10);
|
.HasColumnOrder(10);
|
||||||
|
|
||||||
b.Property<bool>("PhoneNumberConfirmed")
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("phone_number_confirmed")
|
||||||
.HasColumnOrder(11);
|
.HasColumnOrder(11);
|
||||||
|
|
||||||
b.Property<string>("SecurityStamp")
|
b.Property<string>("SecurityStamp")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)")
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("security_stamp")
|
||||||
.HasColumnOrder(8);
|
.HasColumnOrder(8);
|
||||||
|
|
||||||
b.Property<bool>("TwoFactorEnabled")
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("two_factor_enabled")
|
||||||
.HasColumnOrder(12);
|
.HasColumnOrder(12);
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
b.Property<string>("UserName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("user_name")
|
||||||
.HasColumnOrder(2);
|
.HasColumnOrder(2);
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user");
|
||||||
|
|
||||||
b.HasIndex("NormalizedEmail")
|
b.HasIndex("NormalizedEmail")
|
||||||
.HasDatabaseName("EmailIndex");
|
.HasDatabaseName("EmailIndex");
|
||||||
@ -182,116 +212,143 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasDatabaseName("UserNameIndex");
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
b.ToTable("Users", (string)null);
|
b.ToTable("user", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
b.Property<string>("ClaimType")
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("character varying(128)")
|
||||||
|
.HasColumnName("claim_type");
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
b.Property<string>("ClaimValue")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("claim_value");
|
||||||
|
|
||||||
b.Property<int>("RoleId")
|
b.Property<int>("RoleId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("role_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_role_claim");
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
b.HasIndex("RoleId")
|
||||||
|
.HasDatabaseName("ix_role_claim_role_id");
|
||||||
|
|
||||||
b.ToTable("RoleClaims", (string)null);
|
b.ToTable("role_claim", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
b.Property<string>("ClaimType")
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("character varying(128)")
|
||||||
|
.HasColumnName("claim_type");
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
b.Property<string>("ClaimValue")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("claim_value");
|
||||||
|
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user_claim");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId")
|
||||||
|
.HasDatabaseName("ix_user_claim_user_id");
|
||||||
|
|
||||||
b.ToTable("UserClaims", (string)null);
|
b.ToTable("user_claim", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("LoginProvider")
|
b.Property<string>("LoginProvider")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("login_provider");
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
b.Property<string>("ProviderKey")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("provider_key");
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
b.Property<string>("ProviderDisplayName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("provider_display_name");
|
||||||
|
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
b.HasKey("LoginProvider", "ProviderKey")
|
||||||
|
.HasName("pk_user_login");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId")
|
||||||
|
.HasDatabaseName("ix_user_login_user_id");
|
||||||
|
|
||||||
b.ToTable("UserLogins", (string)null);
|
b.ToTable("user_login", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.Property<int>("RoleId")
|
b.Property<int>("RoleId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("role_id");
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
b.HasKey("UserId", "RoleId")
|
||||||
|
.HasName("pk_user_role");
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
b.HasIndex("RoleId")
|
||||||
|
.HasDatabaseName("ix_user_role_role_id");
|
||||||
|
|
||||||
b.ToTable("UserRoles", (string)null);
|
b.ToTable("user_role", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
b.Property<string>("LoginProvider")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("login_provider");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.Property<string>("Value")
|
b.Property<string>("Value")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("value");
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
b.HasKey("UserId", "LoginProvider", "Name")
|
||||||
|
.HasName("pk_user_token");
|
||||||
|
|
||||||
b.ToTable("UserTokens", (string)null);
|
b.ToTable("user_token", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.IdentityService.Entities.PermissionGranted", b =>
|
modelBuilder.Entity("HelloShop.IdentityService.Entities.PermissionGranted", b =>
|
||||||
@ -300,7 +357,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_permission_granted_asp_net_roles_role_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||||
@ -309,7 +367,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_role_claim_asp_net_roles_role_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||||
@ -318,7 +377,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_claim_asp_net_users_user_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||||
@ -327,7 +387,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_login_user_user_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||||
@ -336,13 +397,15 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_role_role_role_id");
|
||||||
|
|
||||||
b.HasOne("HelloShop.IdentityService.Entities.User", null)
|
b.HasOne("HelloShop.IdentityService.Entities.User", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_role_user_user_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||||
@ -351,7 +414,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_token_user_user_id");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
@ -0,0 +1,258 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HelloShop.IdentityService.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "role",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
normalized_name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
concurrency_stamp = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||||
|
creation_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_role", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
user_name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
normalized_user_name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
email = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||||
|
normalized_email = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||||
|
email_confirmed = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
password_hash = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
|
||||||
|
security_stamp = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||||
|
concurrency_stamp = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||||
|
phone_number = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
phone_number_confirmed = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
two_factor_enabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
lockout_end = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||||
|
lockout_enabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
access_failed_count = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
creation_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "permission_granted",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
role_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
permission_name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||||
|
resource_type = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
resource_id = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_permission_granted", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_permission_granted_asp_net_roles_role_id",
|
||||||
|
column: x => x.role_id,
|
||||||
|
principalTable: "role",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "role_claim",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
role_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
claim_type = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||||
|
claim_value = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_role_claim", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_role_claim_asp_net_roles_role_id",
|
||||||
|
column: x => x.role_id,
|
||||||
|
principalTable: "role",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user_claim",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
user_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
claim_type = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||||
|
claim_value = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user_claim", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_user_claim_asp_net_users_user_id",
|
||||||
|
column: x => x.user_id,
|
||||||
|
principalTable: "user",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user_login",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
login_provider = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
provider_key = table.Column<string>(type: "text", nullable: false),
|
||||||
|
provider_display_name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: true),
|
||||||
|
user_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user_login", x => new { x.login_provider, x.provider_key });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_user_login_user_user_id",
|
||||||
|
column: x => x.user_id,
|
||||||
|
principalTable: "user",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user_role",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
user_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
role_id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user_role", x => new { x.user_id, x.role_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_user_role_role_role_id",
|
||||||
|
column: x => x.role_id,
|
||||||
|
principalTable: "role",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_user_role_user_user_id",
|
||||||
|
column: x => x.user_id,
|
||||||
|
principalTable: "user",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "user_token",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
user_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
login_provider = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
value = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_user_token", x => new { x.user_id, x.login_provider, x.name });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_user_token_user_user_id",
|
||||||
|
column: x => x.user_id,
|
||||||
|
principalTable: "user",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_permission_granted_role_id_permission_name_resource_type_re",
|
||||||
|
table: "permission_granted",
|
||||||
|
columns: new[] { "role_id", "permission_name", "resource_type", "resource_id" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "RoleNameIndex",
|
||||||
|
table: "role",
|
||||||
|
column: "normalized_name",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_role_claim_role_id",
|
||||||
|
table: "role_claim",
|
||||||
|
column: "role_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "EmailIndex",
|
||||||
|
table: "user",
|
||||||
|
column: "normalized_email");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "UserNameIndex",
|
||||||
|
table: "user",
|
||||||
|
column: "normalized_user_name",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_user_claim_user_id",
|
||||||
|
table: "user_claim",
|
||||||
|
column: "user_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_user_login_user_id",
|
||||||
|
table: "user_login",
|
||||||
|
column: "user_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_user_role_role_id",
|
||||||
|
table: "user_role",
|
||||||
|
column: "role_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "permission_granted");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "role_claim");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user_claim");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user_login");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user_role");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user_token");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "role");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "user");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
namespace HelloShop.IdentityService.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(IdentityServiceDbContext))]
|
[DbContext(typeof(IdentityServiceDbContext))]
|
||||||
partial class IdentityServiceDbContextModelSnapshot : ModelSnapshot
|
partial class IdentityServiceDbContextModelSnapshot : ModelSnapshot
|
||||||
@ -17,7 +17,7 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.2")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -26,32 +26,39 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("PermissionName")
|
b.Property<string>("PermissionName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("permission_name");
|
||||||
|
|
||||||
b.Property<string>("ResourceId")
|
b.Property<string>("ResourceId")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)");
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("resource_id");
|
||||||
|
|
||||||
b.Property<string>("ResourceType")
|
b.Property<string>("ResourceType")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("resource_type");
|
||||||
|
|
||||||
b.Property<int>("RoleId")
|
b.Property<int>("RoleId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("role_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_permission_granted");
|
||||||
|
|
||||||
b.HasIndex("RoleId", "PermissionName", "ResourceType", "ResourceId")
|
b.HasIndex("RoleId", "PermissionName", "ResourceType", "ResourceId")
|
||||||
.IsUnique();
|
.IsUnique()
|
||||||
|
.HasDatabaseName("ix_permission_granted_role_id_permission_name_resource_type_re");
|
||||||
|
|
||||||
b.ToTable("PermissionGranted", (string)null);
|
b.ToTable("permission_granted", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.IdentityService.Entities.Role", b =>
|
modelBuilder.Entity("HelloShop.IdentityService.Entities.Role", b =>
|
||||||
@ -59,6 +66,7 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
.HasColumnOrder(1);
|
.HasColumnOrder(1);
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
@ -67,29 +75,34 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)")
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("concurrency_stamp")
|
||||||
.HasColumnOrder(4);
|
.HasColumnOrder(4);
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreationTime")
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time")
|
||||||
.HasColumnOrder(5);
|
.HasColumnOrder(5);
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("name")
|
||||||
.HasColumnOrder(2);
|
.HasColumnOrder(2);
|
||||||
|
|
||||||
b.Property<string>("NormalizedName")
|
b.Property<string>("NormalizedName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("normalized_name")
|
||||||
.HasColumnOrder(3);
|
.HasColumnOrder(3);
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_role");
|
||||||
|
|
||||||
b.HasIndex("NormalizedName")
|
b.HasIndex("NormalizedName")
|
||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasDatabaseName("RoleNameIndex");
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
b.ToTable("Roles", (string)null);
|
b.ToTable("role", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.IdentityService.Entities.User", b =>
|
modelBuilder.Entity("HelloShop.IdentityService.Entities.User", b =>
|
||||||
@ -97,80 +110,97 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id")
|
||||||
.HasColumnOrder(1);
|
.HasColumnOrder(1);
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("AccessFailedCount")
|
b.Property<int>("AccessFailedCount")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("access_failed_count")
|
||||||
.HasColumnOrder(15);
|
.HasColumnOrder(15);
|
||||||
|
|
||||||
b.Property<string>("ConcurrencyStamp")
|
b.Property<string>("ConcurrencyStamp")
|
||||||
.IsConcurrencyToken()
|
.IsConcurrencyToken()
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)")
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("concurrency_stamp")
|
||||||
.HasColumnOrder(9);
|
.HasColumnOrder(9);
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreationTime")
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time")
|
||||||
.HasColumnOrder(16);
|
.HasColumnOrder(16);
|
||||||
|
|
||||||
b.Property<string>("Email")
|
b.Property<string>("Email")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)")
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("email")
|
||||||
.HasColumnOrder(4);
|
.HasColumnOrder(4);
|
||||||
|
|
||||||
b.Property<bool>("EmailConfirmed")
|
b.Property<bool>("EmailConfirmed")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("email_confirmed")
|
||||||
.HasColumnOrder(6);
|
.HasColumnOrder(6);
|
||||||
|
|
||||||
b.Property<bool>("LockoutEnabled")
|
b.Property<bool>("LockoutEnabled")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("lockout_enabled")
|
||||||
.HasColumnOrder(14);
|
.HasColumnOrder(14);
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("LockoutEnd")
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("lockout_end")
|
||||||
.HasColumnOrder(13);
|
.HasColumnOrder(13);
|
||||||
|
|
||||||
b.Property<string>("NormalizedEmail")
|
b.Property<string>("NormalizedEmail")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)")
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("normalized_email")
|
||||||
.HasColumnOrder(5);
|
.HasColumnOrder(5);
|
||||||
|
|
||||||
b.Property<string>("NormalizedUserName")
|
b.Property<string>("NormalizedUserName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("normalized_user_name")
|
||||||
.HasColumnOrder(3);
|
.HasColumnOrder(3);
|
||||||
|
|
||||||
b.Property<string>("PasswordHash")
|
b.Property<string>("PasswordHash")
|
||||||
.HasMaxLength(512)
|
.HasMaxLength(512)
|
||||||
.HasColumnType("character varying(512)")
|
.HasColumnType("character varying(512)")
|
||||||
|
.HasColumnName("password_hash")
|
||||||
.HasColumnOrder(7);
|
.HasColumnOrder(7);
|
||||||
|
|
||||||
b.Property<string>("PhoneNumber")
|
b.Property<string>("PhoneNumber")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("phone_number")
|
||||||
.HasColumnOrder(10);
|
.HasColumnOrder(10);
|
||||||
|
|
||||||
b.Property<bool>("PhoneNumberConfirmed")
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("phone_number_confirmed")
|
||||||
.HasColumnOrder(11);
|
.HasColumnOrder(11);
|
||||||
|
|
||||||
b.Property<string>("SecurityStamp")
|
b.Property<string>("SecurityStamp")
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)")
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("security_stamp")
|
||||||
.HasColumnOrder(8);
|
.HasColumnOrder(8);
|
||||||
|
|
||||||
b.Property<bool>("TwoFactorEnabled")
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("two_factor_enabled")
|
||||||
.HasColumnOrder(12);
|
.HasColumnOrder(12);
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
b.Property<string>("UserName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)")
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("user_name")
|
||||||
.HasColumnOrder(2);
|
.HasColumnOrder(2);
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user");
|
||||||
|
|
||||||
b.HasIndex("NormalizedEmail")
|
b.HasIndex("NormalizedEmail")
|
||||||
.HasDatabaseName("EmailIndex");
|
.HasDatabaseName("EmailIndex");
|
||||||
@ -179,116 +209,143 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.IsUnique()
|
.IsUnique()
|
||||||
.HasDatabaseName("UserNameIndex");
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
b.ToTable("Users", (string)null);
|
b.ToTable("user", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
b.Property<string>("ClaimType")
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("character varying(128)")
|
||||||
|
.HasColumnName("claim_type");
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
b.Property<string>("ClaimValue")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("claim_value");
|
||||||
|
|
||||||
b.Property<int>("RoleId")
|
b.Property<int>("RoleId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("role_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_role_claim");
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
b.HasIndex("RoleId")
|
||||||
|
.HasDatabaseName("ix_role_claim_role_id");
|
||||||
|
|
||||||
b.ToTable("RoleClaims", (string)null);
|
b.ToTable("role_claim", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("ClaimType")
|
b.Property<string>("ClaimType")
|
||||||
.HasMaxLength(128)
|
.HasMaxLength(128)
|
||||||
.HasColumnType("character varying(128)");
|
.HasColumnType("character varying(128)")
|
||||||
|
.HasColumnName("claim_type");
|
||||||
|
|
||||||
b.Property<string>("ClaimValue")
|
b.Property<string>("ClaimValue")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("claim_value");
|
||||||
|
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_user_claim");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId")
|
||||||
|
.HasDatabaseName("ix_user_claim_user_id");
|
||||||
|
|
||||||
b.ToTable("UserClaims", (string)null);
|
b.ToTable("user_claim", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("LoginProvider")
|
b.Property<string>("LoginProvider")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("login_provider");
|
||||||
|
|
||||||
b.Property<string>("ProviderKey")
|
b.Property<string>("ProviderKey")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("provider_key");
|
||||||
|
|
||||||
b.Property<string>("ProviderDisplayName")
|
b.Property<string>("ProviderDisplayName")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("provider_display_name");
|
||||||
|
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.HasKey("LoginProvider", "ProviderKey");
|
b.HasKey("LoginProvider", "ProviderKey")
|
||||||
|
.HasName("pk_user_login");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId")
|
||||||
|
.HasDatabaseName("ix_user_login_user_id");
|
||||||
|
|
||||||
b.ToTable("UserLogins", (string)null);
|
b.ToTable("user_login", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.Property<int>("RoleId")
|
b.Property<int>("RoleId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("role_id");
|
||||||
|
|
||||||
b.HasKey("UserId", "RoleId");
|
b.HasKey("UserId", "RoleId")
|
||||||
|
.HasName("pk_user_role");
|
||||||
|
|
||||||
b.HasIndex("RoleId");
|
b.HasIndex("RoleId")
|
||||||
|
.HasDatabaseName("ix_user_role_role_id");
|
||||||
|
|
||||||
b.ToTable("UserRoles", (string)null);
|
b.ToTable("user_role", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("UserId")
|
b.Property<int>("UserId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("user_id");
|
||||||
|
|
||||||
b.Property<string>("LoginProvider")
|
b.Property<string>("LoginProvider")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("login_provider");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.Property<string>("Value")
|
b.Property<string>("Value")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("value");
|
||||||
|
|
||||||
b.HasKey("UserId", "LoginProvider", "Name");
|
b.HasKey("UserId", "LoginProvider", "Name")
|
||||||
|
.HasName("pk_user_token");
|
||||||
|
|
||||||
b.ToTable("UserTokens", (string)null);
|
b.ToTable("user_token", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.IdentityService.Entities.PermissionGranted", b =>
|
modelBuilder.Entity("HelloShop.IdentityService.Entities.PermissionGranted", b =>
|
||||||
@ -297,7 +354,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_permission_granted_asp_net_roles_role_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||||
@ -306,7 +364,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_role_claim_asp_net_roles_role_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||||
@ -315,7 +374,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_claim_asp_net_users_user_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||||
@ -324,7 +384,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_login_user_user_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||||
@ -333,13 +394,15 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("RoleId")
|
.HasForeignKey("RoleId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_role_role_role_id");
|
||||||
|
|
||||||
b.HasOne("HelloShop.IdentityService.Entities.User", null)
|
b.HasOne("HelloShop.IdentityService.Entities.User", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_role_user_user_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||||
@ -348,7 +411,8 @@ namespace HelloShop.IdentityService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("UserId")
|
.HasForeignKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_user_token_user_user_id");
|
||||||
});
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ builder.Services.AddControllers();
|
|||||||
|
|
||||||
builder.Services.AddDbContext<IdentityServiceDbContext>(options =>
|
builder.Services.AddDbContext<IdentityServiceDbContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString(DbConstants.ConnectionStringName));
|
options.UseNpgsql(builder.Configuration.GetConnectionString(DbConstants.ConnectionStringName),x=>x.MigrationsHistoryTable(DbConstants.MigrationsHistoryTableName));
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddIdentity<User, Role>(options =>
|
builder.Services.AddIdentity<User, Role>(options =>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"IdentityDatabase": "Host=localhost;Port=5432;Database=IdentityService;Username=postgres;Password=postgres"
|
"IdentityDatabase": "Host=localhost;Port=5432;Database=identity;Username=postgres;Password=postgres"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,7 @@ namespace HelloShop.OrderingService.Constants
|
|||||||
public const string MasterConnectionStringName = "OrderingDatabaseMaster";
|
public const string MasterConnectionStringName = "OrderingDatabaseMaster";
|
||||||
|
|
||||||
public const string SlaveConnectionStringName = "OrderingDatabaseSlave";
|
public const string SlaveConnectionStringName = "OrderingDatabaseSlave";
|
||||||
|
|
||||||
|
public const string MigrationsHistoryTableName = "migrations_history";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ namespace HelloShop.OrderingService.Extensions
|
|||||||
|
|
||||||
builder.Services.AddDbContext<OrderingServiceDbContext>(options =>
|
builder.Services.AddDbContext<OrderingServiceDbContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString(DbConstants.MasterConnectionStringName));
|
options.UseNpgsql(builder.Configuration.GetConnectionString(DbConstants.MasterConnectionStringName), x => x.MigrationsHistoryTable(DbConstants.MigrationsHistoryTableName));
|
||||||
|
options.UseSnakeCaseNamingConvention();
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddScoped<IClientRequestManager, ClientRequestManager>();
|
builder.Services.AddScoped<IClientRequestManager, ClientRequestManager>();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
|
||||||
<PackageReference Include="MediatR" Version="12.4.1" />
|
<PackageReference Include="MediatR" Version="12.4.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||||
|
@ -11,7 +11,6 @@ namespace HelloShop.OrderingService.Infrastructure.EntityConfigurations.Buyers
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Buyer> builder)
|
public void Configure(EntityTypeBuilder<Buyer> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("Buyer");
|
|
||||||
builder.Property(x => x.Name).HasMaxLength(16).IsRequired();
|
builder.Property(x => x.Name).HasMaxLength(16).IsRequired();
|
||||||
builder.HasMany(b => b.PaymentMethods).WithOne().HasForeignKey(x => x.BuyerId).OnDelete(DeleteBehavior.Cascade);
|
builder.HasMany(b => b.PaymentMethods).WithOne().HasForeignKey(x => x.BuyerId).OnDelete(DeleteBehavior.Cascade);
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,6 @@ namespace HelloShop.OrderingService.Infrastructure.EntityConfigurations.Buyers
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<PaymentMethod> builder)
|
public void Configure(EntityTypeBuilder<PaymentMethod> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("PaymentMethods");
|
|
||||||
|
|
||||||
builder.Property(x => x.Alias).HasMaxLength(16);
|
builder.Property(x => x.Alias).HasMaxLength(16);
|
||||||
builder.Property(x => x.CardNumber).HasMaxLength(16);
|
builder.Property(x => x.CardNumber).HasMaxLength(16);
|
||||||
builder.Property(x => x.CardHolderName).HasMaxLength(16);
|
builder.Property(x => x.CardHolderName).HasMaxLength(16);
|
||||||
|
@ -15,8 +15,6 @@ namespace HelloShop.OrderingService.Infrastructure.EntityConfigurations.EventLog
|
|||||||
|
|
||||||
public void Configure(EntityTypeBuilder<DistributedEventLog> builder)
|
public void Configure(EntityTypeBuilder<DistributedEventLog> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("DistributedEventLogs");
|
|
||||||
|
|
||||||
builder.HasKey(x => x.EventId);
|
builder.HasKey(x => x.EventId);
|
||||||
builder.Property(x => x.EventTypeName).HasMaxLength(32);
|
builder.Property(x => x.EventTypeName).HasMaxLength(32);
|
||||||
builder.Property(x => x.Status).HasConversion<string>();
|
builder.Property(x => x.Status).HasConversion<string>();
|
||||||
|
@ -11,8 +11,6 @@ namespace HelloShop.OrderingService.Infrastructure.EntityConfigurations.Idempote
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<ClientRequest> builder)
|
public void Configure(EntityTypeBuilder<ClientRequest> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("ClientRequests");
|
|
||||||
|
|
||||||
builder.HasKey(t => t.Id);
|
builder.HasKey(t => t.Id);
|
||||||
|
|
||||||
builder.Property(t => t.Name).HasMaxLength(64);
|
builder.Property(t => t.Name).HasMaxLength(64);
|
||||||
|
@ -12,8 +12,6 @@ namespace HelloShop.OrderingService.Infrastructure.EntityConfigurations.Orders
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Order> builder)
|
public void Configure(EntityTypeBuilder<Order> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("Orders");
|
|
||||||
|
|
||||||
builder.Property(x => x.Description).HasMaxLength(64);
|
builder.Property(x => x.Description).HasMaxLength(64);
|
||||||
builder.Property(x => x.OrderStatus).HasConversion<string>();
|
builder.Property(x => x.OrderStatus).HasConversion<string>();
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ namespace HelloShop.OrderingService.Infrastructure.EntityConfigurations.Orders
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<OrderItem> builder)
|
public void Configure(EntityTypeBuilder<OrderItem> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("OrderItems");
|
|
||||||
|
|
||||||
builder.Property(x => x.ProductName).HasMaxLength(16);
|
builder.Property(x => x.ProductName).HasMaxLength(16);
|
||||||
builder.Property(x => x.PictureUrl).HasMaxLength(256);
|
builder.Property(x => x.PictureUrl).HasMaxLength(256);
|
||||||
}
|
}
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
|
||||||
// See the license file in the project root for more information.
|
|
||||||
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Buyer",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Buyer", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PaymentMethods",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
BuyerId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
Alias = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
CardNumber = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
CardHolderName = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
SecurityNumber = table.Column<string>(type: "character varying(6)", maxLength: 6, nullable: true),
|
|
||||||
Expiration = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PaymentMethods", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PaymentMethods_Buyer_BuyerId",
|
|
||||||
column: x => x.BuyerId,
|
|
||||||
principalTable: "Buyer",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
OrderDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
Country = table.Column<string>(type: "character varying(8)", maxLength: 8, nullable: false),
|
|
||||||
State = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
City = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
Street = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
|
||||||
ZipCode = table.Column<string>(type: "character varying(6)", maxLength: 6, nullable: false),
|
|
||||||
OrderStatus = table.Column<string>(type: "text", nullable: false),
|
|
||||||
BuyerId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
PaymentMethodId = table.Column<int>(type: "integer", nullable: true),
|
|
||||||
Description = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Buyer_BuyerId",
|
|
||||||
column: x => x.BuyerId,
|
|
||||||
principalTable: "Buyer",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_PaymentMethods_PaymentMethodId",
|
|
||||||
column: x => x.PaymentMethodId,
|
|
||||||
principalTable: "PaymentMethods",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "OrderItems",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
OrderId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ProductId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ProductName = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
|
||||||
PictureUrl = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
||||||
UnitPrice = table.Column<decimal>(type: "numeric", nullable: false),
|
|
||||||
Units = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_OrderItems", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_OrderItems_Orders_OrderId",
|
|
||||||
column: x => x.OrderId,
|
|
||||||
principalTable: "Orders",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_OrderItems_OrderId",
|
|
||||||
table: "OrderItems",
|
|
||||||
column: "OrderId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_BuyerId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "BuyerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_PaymentMethodId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "PaymentMethodId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PaymentMethods_BuyerId",
|
|
||||||
table: "PaymentMethods",
|
|
||||||
column: "BuyerId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "OrderItems");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PaymentMethods");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Buyer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace HelloShop.OrderingService.Infrastructure.Migrations
|
namespace HelloShop.OrderingService.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(OrderingServiceDbContext))]
|
[DbContext(typeof(OrderingServiceDbContext))]
|
||||||
[Migration("20240829142135_InitialCreate")]
|
[Migration("20241123020913_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -20,7 +20,7 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.8")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -29,129 +29,223 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_buyer");
|
||||||
|
|
||||||
b.ToTable("Buyer", (string)null);
|
b.ToTable("buyer", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Alias")
|
b.Property<string>("Alias")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("alias");
|
||||||
|
|
||||||
b.Property<int>("BuyerId")
|
b.Property<int>("BuyerId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("buyer_id");
|
||||||
|
|
||||||
b.Property<string>("CardHolderName")
|
b.Property<string>("CardHolderName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("card_holder_name");
|
||||||
|
|
||||||
b.Property<string>("CardNumber")
|
b.Property<string>("CardNumber")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("card_number");
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("Expiration")
|
b.Property<DateTimeOffset?>("Expiration")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("expiration");
|
||||||
|
|
||||||
b.Property<string>("SecurityNumber")
|
b.Property<string>("SecurityNumber")
|
||||||
.HasMaxLength(6)
|
.HasMaxLength(6)
|
||||||
.HasColumnType("character varying(6)");
|
.HasColumnType("character varying(6)")
|
||||||
|
.HasColumnName("security_number");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_payment_method");
|
||||||
|
|
||||||
b.HasIndex("BuyerId");
|
b.HasIndex("BuyerId")
|
||||||
|
.HasDatabaseName("ix_payment_method_buyer_id");
|
||||||
|
|
||||||
b.ToTable("PaymentMethods", (string)null);
|
b.ToTable("payment_method", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.EventLogs.DistributedEventLog", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("EventId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("event_id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time");
|
||||||
|
|
||||||
|
b.Property<string>("DistributedEvent")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("distributed_event");
|
||||||
|
|
||||||
|
b.Property<string>("EventTypeName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("event_type_name");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("status");
|
||||||
|
|
||||||
|
b.Property<int>("TimesSent")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("times_sent");
|
||||||
|
|
||||||
|
b.Property<Guid>("TransactionId")
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("transaction_id");
|
||||||
|
|
||||||
|
b.HasKey("EventId")
|
||||||
|
.HasName("pk_distributed_event_log");
|
||||||
|
|
||||||
|
b.ToTable("distributed_event_log", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Idempotency.ClientRequest", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Time")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("time");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_client_request");
|
||||||
|
|
||||||
|
b.ToTable("client_request", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("BuyerId")
|
b.Property<int>("BuyerId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("buyer_id");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("description");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("OrderDate")
|
b.Property<DateTimeOffset>("OrderDate")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("order_date");
|
||||||
|
|
||||||
b.Property<string>("OrderStatus")
|
b.Property<string>("OrderStatus")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("order_status");
|
||||||
|
|
||||||
b.Property<int?>("PaymentMethodId")
|
b.Property<int?>("PaymentMethodId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("payment_method_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_order");
|
||||||
|
|
||||||
b.HasIndex("BuyerId");
|
b.HasIndex("BuyerId")
|
||||||
|
.HasDatabaseName("ix_order_buyer_id");
|
||||||
|
|
||||||
b.HasIndex("PaymentMethodId");
|
b.HasIndex("PaymentMethodId")
|
||||||
|
.HasDatabaseName("ix_order_payment_method_id");
|
||||||
|
|
||||||
b.ToTable("Orders", (string)null);
|
b.ToTable("order", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.OrderItem", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.OrderItem", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("OrderId")
|
b.Property<int>("OrderId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("order_id");
|
||||||
|
|
||||||
b.Property<string>("PictureUrl")
|
b.Property<string>("PictureUrl")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)")
|
||||||
|
.HasColumnName("picture_url");
|
||||||
|
|
||||||
b.Property<int>("ProductId")
|
b.Property<int>("ProductId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("product_id");
|
||||||
|
|
||||||
b.Property<string>("ProductName")
|
b.Property<string>("ProductName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("product_name");
|
||||||
|
|
||||||
b.Property<decimal>("UnitPrice")
|
b.Property<decimal>("UnitPrice")
|
||||||
.HasColumnType("numeric");
|
.HasColumnType("numeric")
|
||||||
|
.HasColumnName("unit_price");
|
||||||
|
|
||||||
b.Property<int>("Units")
|
b.Property<int>("Units")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("units");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_order_item");
|
||||||
|
|
||||||
b.HasIndex("OrderId");
|
b.HasIndex("OrderId")
|
||||||
|
.HasDatabaseName("ix_order_item_order_id");
|
||||||
|
|
||||||
b.ToTable("OrderItems", (string)null);
|
b.ToTable("order_item", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
||||||
@ -160,7 +254,8 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
.WithMany("PaymentMethods")
|
.WithMany("PaymentMethods")
|
||||||
.HasForeignKey("BuyerId")
|
.HasForeignKey("BuyerId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_payment_method_buyer_buyer_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
||||||
@ -169,17 +264,20 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("BuyerId")
|
.HasForeignKey("BuyerId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_order_buyer_buyer_id");
|
||||||
|
|
||||||
b.HasOne("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", null)
|
b.HasOne("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("PaymentMethodId")
|
.HasForeignKey("PaymentMethodId")
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.HasConstraintName("fk_order_payment_method_payment_method_id");
|
||||||
|
|
||||||
b.OwnsOne("HelloShop.OrderingService.Entities.Orders.Address", "Address", b1 =>
|
b.OwnsOne("HelloShop.OrderingService.Entities.Orders.Address", "Address", b1 =>
|
||||||
{
|
{
|
||||||
b1.Property<int>("OrderId")
|
b1.Property<int>("OrderId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
b1.Property<string>("City")
|
b1.Property<string>("City")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
@ -213,10 +311,11 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
|
|
||||||
b1.HasKey("OrderId");
|
b1.HasKey("OrderId");
|
||||||
|
|
||||||
b1.ToTable("Orders");
|
b1.ToTable("order");
|
||||||
|
|
||||||
b1.WithOwner()
|
b1.WithOwner()
|
||||||
.HasForeignKey("OrderId");
|
.HasForeignKey("OrderId")
|
||||||
|
.HasConstraintName("fk_order_order_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
b.Navigation("Address")
|
b.Navigation("Address")
|
||||||
@ -229,7 +328,8 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
.WithMany("OrderItems")
|
.WithMany("OrderItems")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_order_item_order_order_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.Buyer", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.Buyer", b =>
|
@ -0,0 +1,183 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HelloShop.OrderingService.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "buyer",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_buyer", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "client_request",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||||
|
time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_client_request", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "distributed_event_log",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
event_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
event_type_name = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||||
|
distributed_event = table.Column<string>(type: "text", nullable: false),
|
||||||
|
status = table.Column<string>(type: "text", nullable: false),
|
||||||
|
times_sent = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
creation_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
transaction_id = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_distributed_event_log", x => x.event_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "payment_method",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
buyer_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
alias = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
card_number = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
card_holder_name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
security_number = table.Column<string>(type: "character varying(6)", maxLength: 6, nullable: true),
|
||||||
|
expiration = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_payment_method", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_payment_method_buyer_buyer_id",
|
||||||
|
column: x => x.buyer_id,
|
||||||
|
principalTable: "buyer",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "order",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
order_date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
Country = table.Column<string>(type: "character varying(8)", maxLength: 8, nullable: false),
|
||||||
|
State = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
City = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
Street = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
||||||
|
ZipCode = table.Column<string>(type: "character varying(6)", maxLength: 6, nullable: false),
|
||||||
|
order_status = table.Column<string>(type: "text", nullable: false),
|
||||||
|
buyer_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
payment_method_id = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
description = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_order", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_order_buyer_buyer_id",
|
||||||
|
column: x => x.buyer_id,
|
||||||
|
principalTable: "buyer",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_order_payment_method_payment_method_id",
|
||||||
|
column: x => x.payment_method_id,
|
||||||
|
principalTable: "payment_method",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "order_item",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
order_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
product_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
product_name = table.Column<string>(type: "character varying(16)", maxLength: 16, nullable: false),
|
||||||
|
picture_url = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||||
|
unit_price = table.Column<decimal>(type: "numeric", nullable: false),
|
||||||
|
units = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_order_item", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_order_item_order_order_id",
|
||||||
|
column: x => x.order_id,
|
||||||
|
principalTable: "order",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_order_buyer_id",
|
||||||
|
table: "order",
|
||||||
|
column: "buyer_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_order_payment_method_id",
|
||||||
|
table: "order",
|
||||||
|
column: "payment_method_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_order_item_order_id",
|
||||||
|
table: "order_item",
|
||||||
|
column: "order_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_payment_method_buyer_id",
|
||||||
|
table: "payment_method",
|
||||||
|
column: "buyer_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "client_request");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "distributed_event_log");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "order_item");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "order");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "payment_method");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "buyer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.8")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -26,129 +26,223 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_buyer");
|
||||||
|
|
||||||
b.ToTable("Buyer", (string)null);
|
b.ToTable("buyer", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Alias")
|
b.Property<string>("Alias")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("alias");
|
||||||
|
|
||||||
b.Property<int>("BuyerId")
|
b.Property<int>("BuyerId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("buyer_id");
|
||||||
|
|
||||||
b.Property<string>("CardHolderName")
|
b.Property<string>("CardHolderName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("card_holder_name");
|
||||||
|
|
||||||
b.Property<string>("CardNumber")
|
b.Property<string>("CardNumber")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("card_number");
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("Expiration")
|
b.Property<DateTimeOffset?>("Expiration")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("expiration");
|
||||||
|
|
||||||
b.Property<string>("SecurityNumber")
|
b.Property<string>("SecurityNumber")
|
||||||
.HasMaxLength(6)
|
.HasMaxLength(6)
|
||||||
.HasColumnType("character varying(6)");
|
.HasColumnType("character varying(6)")
|
||||||
|
.HasColumnName("security_number");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_payment_method");
|
||||||
|
|
||||||
b.HasIndex("BuyerId");
|
b.HasIndex("BuyerId")
|
||||||
|
.HasDatabaseName("ix_payment_method_buyer_id");
|
||||||
|
|
||||||
b.ToTable("PaymentMethods", (string)null);
|
b.ToTable("payment_method", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.EventLogs.DistributedEventLog", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("EventId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("event_id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time");
|
||||||
|
|
||||||
|
b.Property<string>("DistributedEvent")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("distributed_event");
|
||||||
|
|
||||||
|
b.Property<string>("EventTypeName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(32)
|
||||||
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("event_type_name");
|
||||||
|
|
||||||
|
b.Property<string>("Status")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("status");
|
||||||
|
|
||||||
|
b.Property<int>("TimesSent")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("times_sent");
|
||||||
|
|
||||||
|
b.Property<Guid>("TransactionId")
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("transaction_id");
|
||||||
|
|
||||||
|
b.HasKey("EventId")
|
||||||
|
.HasName("pk_distributed_event_log");
|
||||||
|
|
||||||
|
b.ToTable("distributed_event_log", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Idempotency.ClientRequest", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(64)
|
||||||
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Time")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("time");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_client_request");
|
||||||
|
|
||||||
|
b.ToTable("client_request", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("BuyerId")
|
b.Property<int>("BuyerId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("buyer_id");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasMaxLength(64)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(64)");
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("description");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("OrderDate")
|
b.Property<DateTimeOffset>("OrderDate")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("order_date");
|
||||||
|
|
||||||
b.Property<string>("OrderStatus")
|
b.Property<string>("OrderStatus")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("order_status");
|
||||||
|
|
||||||
b.Property<int?>("PaymentMethodId")
|
b.Property<int?>("PaymentMethodId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("payment_method_id");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_order");
|
||||||
|
|
||||||
b.HasIndex("BuyerId");
|
b.HasIndex("BuyerId")
|
||||||
|
.HasDatabaseName("ix_order_buyer_id");
|
||||||
|
|
||||||
b.HasIndex("PaymentMethodId");
|
b.HasIndex("PaymentMethodId")
|
||||||
|
.HasDatabaseName("ix_order_payment_method_id");
|
||||||
|
|
||||||
b.ToTable("Orders", (string)null);
|
b.ToTable("order", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.OrderItem", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.OrderItem", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<int>("OrderId")
|
b.Property<int>("OrderId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("order_id");
|
||||||
|
|
||||||
b.Property<string>("PictureUrl")
|
b.Property<string>("PictureUrl")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)")
|
||||||
|
.HasColumnName("picture_url");
|
||||||
|
|
||||||
b.Property<int>("ProductId")
|
b.Property<int>("ProductId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("product_id");
|
||||||
|
|
||||||
b.Property<string>("ProductName")
|
b.Property<string>("ProductName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(16)
|
.HasMaxLength(16)
|
||||||
.HasColumnType("character varying(16)");
|
.HasColumnType("character varying(16)")
|
||||||
|
.HasColumnName("product_name");
|
||||||
|
|
||||||
b.Property<decimal>("UnitPrice")
|
b.Property<decimal>("UnitPrice")
|
||||||
.HasColumnType("numeric");
|
.HasColumnType("numeric")
|
||||||
|
.HasColumnName("unit_price");
|
||||||
|
|
||||||
b.Property<int>("Units")
|
b.Property<int>("Units")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("units");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_order_item");
|
||||||
|
|
||||||
b.HasIndex("OrderId");
|
b.HasIndex("OrderId")
|
||||||
|
.HasDatabaseName("ix_order_item_order_id");
|
||||||
|
|
||||||
b.ToTable("OrderItems", (string)null);
|
b.ToTable("order_item", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", b =>
|
||||||
@ -157,7 +251,8 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
.WithMany("PaymentMethods")
|
.WithMany("PaymentMethods")
|
||||||
.HasForeignKey("BuyerId")
|
.HasForeignKey("BuyerId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_payment_method_buyer_buyer_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Orders.Order", b =>
|
||||||
@ -166,17 +261,20 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("BuyerId")
|
.HasForeignKey("BuyerId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_order_buyer_buyer_id");
|
||||||
|
|
||||||
b.HasOne("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", null)
|
b.HasOne("HelloShop.OrderingService.Entities.Buyers.PaymentMethod", null)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("PaymentMethodId")
|
.HasForeignKey("PaymentMethodId")
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.HasConstraintName("fk_order_payment_method_payment_method_id");
|
||||||
|
|
||||||
b.OwnsOne("HelloShop.OrderingService.Entities.Orders.Address", "Address", b1 =>
|
b.OwnsOne("HelloShop.OrderingService.Entities.Orders.Address", "Address", b1 =>
|
||||||
{
|
{
|
||||||
b1.Property<int>("OrderId")
|
b1.Property<int>("OrderId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
b1.Property<string>("City")
|
b1.Property<string>("City")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
@ -210,10 +308,11 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
|
|
||||||
b1.HasKey("OrderId");
|
b1.HasKey("OrderId");
|
||||||
|
|
||||||
b1.ToTable("Orders");
|
b1.ToTable("order");
|
||||||
|
|
||||||
b1.WithOwner()
|
b1.WithOwner()
|
||||||
.HasForeignKey("OrderId");
|
.HasForeignKey("OrderId")
|
||||||
|
.HasConstraintName("fk_order_order_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
b.Navigation("Address")
|
b.Navigation("Address")
|
||||||
@ -226,7 +325,8 @@ namespace HelloShop.OrderingService.Infrastructure.Migrations
|
|||||||
.WithMany("OrderItems")
|
.WithMany("OrderItems")
|
||||||
.HasForeignKey("OrderId")
|
.HasForeignKey("OrderId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_order_item_order_order_id");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.Buyer", b =>
|
modelBuilder.Entity("HelloShop.OrderingService.Entities.Buyers.Buyer", b =>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"OrderingDatabaseMaster": "Host=localhost;Port=5432;Database=OrderingService;Username=postgres;Password=postgres",
|
"OrderingDatabaseMaster": "Host=localhost;Port=5432;Database=ordering;Username=postgres;Password=postgres",
|
||||||
"OrderingDatabaseSlave": "Host=localhost;Port=5432;Database=OrderingService;Username=postgres;Password=postgres"
|
"OrderingDatabaseSlave": "Host=localhost;Port=5432;Database=ordering;Username=postgres;Password=postgres"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,4 +6,6 @@ namespace HelloShop.ProductService.Constants;
|
|||||||
public static class DbConstants
|
public static class DbConstants
|
||||||
{
|
{
|
||||||
public const string ConnectionStringName = "ProductDatabase";
|
public const string ConnectionStringName = "ProductDatabase";
|
||||||
|
|
||||||
|
public const string MigrationsHistoryTableName = "migrations_history";
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
<ProjectReference Include="..\HelloShop.ServiceDefaults\HelloShop.ServiceDefaults.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
@ -11,7 +11,6 @@ public class BrandEntityTypeConfiguration : IEntityTypeConfiguration<Brand>
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Brand> builder)
|
public void Configure(EntityTypeBuilder<Brand> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("Brands");
|
|
||||||
builder.Property(x => x.Name).HasMaxLength(32);
|
builder.Property(x => x.Name).HasMaxLength(32);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,12 +11,8 @@ public class ProductEntityTypeConfiguration : IEntityTypeConfiguration<Product>
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<Product> builder)
|
public void Configure(EntityTypeBuilder<Product> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("Products");
|
|
||||||
|
|
||||||
builder.Property(x => x.Name).HasMaxLength(64);
|
builder.Property(x => x.Name).HasMaxLength(64);
|
||||||
|
|
||||||
builder.Property(x => x.ImageUrl).HasMaxLength(256);
|
builder.Property(x => x.ImageUrl).HasMaxLength(256);
|
||||||
|
|
||||||
builder.HasOne(x => x.Brand).WithMany();
|
builder.HasOne(x => x.Brand).WithMany();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
|
||||||
// See the license file in the project root for more information.
|
|
||||||
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class InitialCreate : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Brands",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Name = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Brands", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Products",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "integer", nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
Name = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
|
||||||
Description = table.Column<string>(type: "text", nullable: true),
|
|
||||||
Price = table.Column<decimal>(type: "numeric", nullable: false),
|
|
||||||
BrandId = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
ImageUrl = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
||||||
CreationTime = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Products", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Products_Brands_BrandId",
|
|
||||||
column: x => x.BrandId,
|
|
||||||
principalTable: "Brands",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Products_BrandId",
|
|
||||||
table: "Products",
|
|
||||||
column: "BrandId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Products");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Brands");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,10 +9,10 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
namespace HelloShop.ProductService.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ProductServiceDbContext))]
|
[DbContext(typeof(ProductServiceDbContext))]
|
||||||
[Migration("20240419145737_InitialCreate")]
|
[Migration("20241123020927_InitialCreate")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -20,7 +20,7 @@ namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.4")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -29,54 +29,72 @@ namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)");
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_brand");
|
||||||
|
|
||||||
b.ToTable("Brands", (string)null);
|
b.ToTable("brand", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("AvailableStock")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("available_stock");
|
||||||
|
|
||||||
b.Property<int>("BrandId")
|
b.Property<int>("BrandId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("brand_id");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreationTime")
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasColumnType("text");
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("description");
|
||||||
|
|
||||||
b.Property<string>("ImageUrl")
|
b.Property<string>("ImageUrl")
|
||||||
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)")
|
||||||
|
.HasColumnName("image_url");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(32)");
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.Property<decimal>("Price")
|
b.Property<decimal>("Price")
|
||||||
.HasColumnType("numeric");
|
.HasColumnType("numeric")
|
||||||
|
.HasColumnName("price");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_product");
|
||||||
|
|
||||||
b.HasIndex("BrandId");
|
b.HasIndex("BrandId")
|
||||||
|
.HasDatabaseName("ix_product_brand_id");
|
||||||
|
|
||||||
b.ToTable("Products", (string)null);
|
b.ToTable("product", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
||||||
@ -85,7 +103,8 @@ namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("BrandId")
|
.HasForeignKey("BrandId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_product_brand_brand_id");
|
||||||
|
|
||||||
b.Navigation("Brand");
|
b.Navigation("Brand");
|
||||||
});
|
});
|
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HelloShop.ProductService.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "brand",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_brand", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "product",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||||
|
description = table.Column<string>(type: "text", nullable: false),
|
||||||
|
price = table.Column<decimal>(type: "numeric", nullable: false),
|
||||||
|
brand_id = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
image_url = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
||||||
|
available_stock = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
creation_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_product", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_product_brand_brand_id",
|
||||||
|
column: x => x.brand_id,
|
||||||
|
principalTable: "brand",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_product_brand_id",
|
||||||
|
table: "product",
|
||||||
|
column: "brand_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "product");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "brand");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
namespace HelloShop.ProductService.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(ProductServiceDbContext))]
|
[DbContext(typeof(ProductServiceDbContext))]
|
||||||
partial class ProductServiceDbContextModelSnapshot : ModelSnapshot
|
partial class ProductServiceDbContextModelSnapshot : ModelSnapshot
|
||||||
@ -17,7 +17,7 @@ namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.4")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -26,54 +26,72 @@ namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(32)
|
||||||
.HasColumnType("character varying(32)");
|
.HasColumnType("character varying(32)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_brand");
|
||||||
|
|
||||||
b.ToTable("Brands", (string)null);
|
b.ToTable("brand", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("AvailableStock")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("available_stock");
|
||||||
|
|
||||||
b.Property<int>("BrandId")
|
b.Property<int>("BrandId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("brand_id");
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("CreationTime")
|
b.Property<DateTimeOffset>("CreationTime")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("creation_time");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasColumnType("text");
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("description");
|
||||||
|
|
||||||
b.Property<string>("ImageUrl")
|
b.Property<string>("ImageUrl")
|
||||||
|
.IsRequired()
|
||||||
.HasMaxLength(256)
|
.HasMaxLength(256)
|
||||||
.HasColumnType("character varying(256)");
|
.HasColumnType("character varying(256)")
|
||||||
|
.HasColumnName("image_url");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(32)
|
.HasMaxLength(64)
|
||||||
.HasColumnType("character varying(32)");
|
.HasColumnType("character varying(64)")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
b.Property<decimal>("Price")
|
b.Property<decimal>("Price")
|
||||||
.HasColumnType("numeric");
|
.HasColumnType("numeric")
|
||||||
|
.HasColumnName("price");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_product");
|
||||||
|
|
||||||
b.HasIndex("BrandId");
|
b.HasIndex("BrandId")
|
||||||
|
.HasDatabaseName("ix_product_brand_id");
|
||||||
|
|
||||||
b.ToTable("Products", (string)null);
|
b.ToTable("product", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
modelBuilder.Entity("HelloShop.ProductService.Entities.Products.Product", b =>
|
||||||
@ -82,7 +100,8 @@ namespace HelloShop.ProductService.EntityFrameworks.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("BrandId")
|
.HasForeignKey("BrandId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired()
|
||||||
|
.HasConstraintName("fk_product_brand_brand_id");
|
||||||
|
|
||||||
b.Navigation("Brand");
|
b.Navigation("Brand");
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,8 @@ builder.Services.AddControllers();
|
|||||||
// Add extensions services to the container.
|
// Add extensions services to the container.
|
||||||
builder.Services.AddDbContext<ProductServiceDbContext>(options =>
|
builder.Services.AddDbContext<ProductServiceDbContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseNpgsql(builder.Configuration.GetConnectionString(DbConstants.ConnectionStringName));
|
options.UseNpgsql(builder.Configuration.GetConnectionString(DbConstants.ConnectionStringName), x => x.MigrationsHistoryTable(DbConstants.MigrationsHistoryTableName));
|
||||||
|
options.UseSnakeCaseNamingConvention();
|
||||||
});
|
});
|
||||||
builder.Services.AddHttpClient().AddHttpContextAccessor().AddDistributedMemoryCache();
|
builder.Services.AddHttpClient().AddHttpContextAccessor().AddDistributedMemoryCache();
|
||||||
builder.Services.AddDataSeedingProviders();
|
builder.Services.AddDataSeedingProviders();
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"ProductDatabase": "Host=localhost;Port=5432;Database=ProductService;Username=postgres;Password=postgres"
|
"ProductDatabase": "Host=localhost;Port=5432;Database=product;Username=postgres;Password=postgres"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user