Init
This commit is contained in:
52
Prefab.Web/Data/AppDb.cs
Normal file
52
Prefab.Web/Data/AppDb.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prefab.Catalog.Domain.Entities;
|
||||
using Prefab.Data;
|
||||
using Prefab.Handler;
|
||||
|
||||
namespace Prefab.Web.Data;
|
||||
|
||||
public class AppDb : PrefabDb, IPrefabDb,
|
||||
Prefab.Catalog.Data.IModuleDb
|
||||
{
|
||||
public AppDb(DbContextOptions<AppDb> options, IHandlerContextAccessor accessor)
|
||||
: base(options, accessor)
|
||||
{
|
||||
}
|
||||
|
||||
protected AppDb(DbContextOptions options, IHandlerContextAccessor accessor)
|
||||
: base(options, accessor)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void PrefabOnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
builder.ApplyConfigurationsFromAssembly(typeof(Prefab.Catalog.Data.IModuleDb).Assembly);
|
||||
}
|
||||
|
||||
protected override void PrefabOnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
// Additional write-context configuration can be applied here if needed.
|
||||
}
|
||||
|
||||
public DbSet<Category> Categories => Set<Category>();
|
||||
|
||||
public DbSet<Product> Products => Set<Product>();
|
||||
|
||||
public DbSet<OptionDefinition> OptionDefinitions => Set<OptionDefinition>();
|
||||
|
||||
public DbSet<OptionValue> OptionValues => Set<OptionValue>();
|
||||
|
||||
public DbSet<OptionTier> OptionTiers => Set<OptionTier>();
|
||||
|
||||
public DbSet<OptionRuleSet> OptionRuleSets => Set<OptionRuleSet>();
|
||||
|
||||
public DbSet<OptionRuleCondition> OptionRuleConditions => Set<OptionRuleCondition>();
|
||||
|
||||
public DbSet<VariantAxisValue> VariantAxisValues => Set<VariantAxisValue>();
|
||||
|
||||
public DbSet<AttributeDefinition> AttributeDefinitions => Set<AttributeDefinition>();
|
||||
|
||||
public DbSet<ProductAttributeValue> ProductAttributeValues => Set<ProductAttributeValue>();
|
||||
|
||||
public DbSet<ProductCategory> ProductCategories => Set<ProductCategory>();
|
||||
}
|
||||
20
Prefab.Web/Data/AppDbReadOnly.cs
Normal file
20
Prefab.Web/Data/AppDbReadOnly.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prefab.Handler;
|
||||
|
||||
namespace Prefab.Web.Data;
|
||||
|
||||
public class AppDbReadOnly(DbContextOptions<AppDbReadOnly> options, IHandlerContextAccessor accessor) : AppDb(options, accessor), Prefab.Data.IPrefabDbReadOnly,
|
||||
Prefab.Catalog.Data.IModuleDbReadOnly
|
||||
{
|
||||
protected override void PrefabOnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
base.PrefabOnConfiguring(optionsBuilder);
|
||||
optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
||||
}
|
||||
|
||||
public override int SaveChanges()
|
||||
=> throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed.");
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
=> throw new InvalidOperationException("This database context is read-only. Saving changes is not allowed.");
|
||||
}
|
||||
16
Prefab.Web/Data/CatalogDbContextFactory.cs
Normal file
16
Prefab.Web/Data/CatalogDbContextFactory.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Prefab.Catalog.Data;
|
||||
|
||||
namespace Prefab.Web.Data;
|
||||
|
||||
internal sealed class CatalogDbContextFactory(
|
||||
IDbContextFactory<AppDb> writeFactory,
|
||||
IDbContextFactory<AppDbReadOnly> readFactory) : ICatalogDbContextFactory
|
||||
{
|
||||
public async ValueTask<IModuleDb> CreateWritableAsync(CancellationToken cancellationToken = default) =>
|
||||
await writeFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
public async ValueTask<IModuleDbReadOnly> CreateReadOnlyAsync(CancellationToken cancellationToken = default) =>
|
||||
await readFactory.CreateDbContextAsync(cancellationToken);
|
||||
}
|
||||
|
||||
1026
Prefab.Web/Data/Migrations/20251024202413_Initial.Designer.cs
generated
Normal file
1026
Prefab.Web/Data/Migrations/20251024202413_Initial.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
653
Prefab.Web/Data/Migrations/20251024202413_Initial.cs
Normal file
653
Prefab.Web/Data/Migrations/20251024202413_Initial.cs
Normal file
@@ -0,0 +1,653 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Prefab.Web.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "catalog");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AttributeDefinitions",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
||||
DataType = table.Column<int>(type: "int", nullable: false),
|
||||
Unit = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AttributeDefinitions", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AuditLogs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CorrelationId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Entity = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
|
||||
State = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AuditLogs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Categories",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||
Slug = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
|
||||
DisplayOrder = table.Column<int>(type: "int", nullable: false),
|
||||
IsFeatured = table.Column<bool>(type: "bit", nullable: false),
|
||||
HeroImageUrl = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
|
||||
Icon = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Categories", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GenericAttributes",
|
||||
columns: table => new
|
||||
{
|
||||
EntityId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
KeyGroup = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
|
||||
Key = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
|
||||
Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Value = table.Column<string>(type: "nvarchar(max)", maxLength: 2147483647, nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GenericAttributes", x => new { x.EntityId, x.KeyGroup, x.Key });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Products",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Kind = table.Column<int>(type: "int", nullable: false),
|
||||
Sku = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
|
||||
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
||||
Slug = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
|
||||
Description = table.Column<string>(type: "nvarchar(2048)", maxLength: 2048, nullable: true),
|
||||
Price = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true),
|
||||
ParentProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Products", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Products_Products_ParentProductId",
|
||||
column: x => x.ParentProductId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SeederLogs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SeederName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
||||
RunMode = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
|
||||
RunAt = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SeederLogs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AuditLogItems",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AuditLogId = table.Column<int>(type: "int", nullable: false),
|
||||
Property = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||
OldValue = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
|
||||
NewValue = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AuditLogItems", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_AuditLogItems_AuditLogs_AuditLogId",
|
||||
column: x => x.AuditLogId,
|
||||
principalTable: "AuditLogs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OptionDefinitions",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Code = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
||||
DataType = table.Column<int>(type: "int", nullable: false),
|
||||
IsVariantAxis = table.Column<bool>(type: "bit", nullable: false),
|
||||
Unit = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
|
||||
Min = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
Max = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
Step = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
PricePerUnit = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
PercentScope = table.Column<int>(type: "int", nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OptionDefinitions", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionDefinitions_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OptionRuleSets",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
TargetKind = table.Column<byte>(type: "tinyint", nullable: false),
|
||||
TargetId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Effect = table.Column<byte>(type: "tinyint", nullable: false),
|
||||
Mode = table.Column<byte>(type: "tinyint", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OptionRuleSets", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionRuleSets_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductAttributeValues",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
AttributeDefinitionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Value = table.Column<string>(type: "nvarchar(1024)", maxLength: 1024, nullable: true),
|
||||
NumericValue = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
UnitCode = table.Column<string>(type: "nvarchar(32)", maxLength: 32, nullable: true),
|
||||
EnumCode = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductAttributeValues", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductAttributeValues_AttributeDefinitions_AttributeDefinitionId",
|
||||
column: x => x.AttributeDefinitionId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "AttributeDefinitions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductAttributeValues_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProductCategories",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
ProductId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
IsPrimary = table.Column<bool>(type: "bit", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProductCategories", x => new { x.ProductId, x.CategoryId });
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductCategories_Categories_CategoryId",
|
||||
column: x => x.CategoryId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Categories",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductCategories_Products_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OptionTiers",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
OptionDefinitionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
FromInclusive = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
|
||||
ToInclusive = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
UnitRate = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: false),
|
||||
FlatDelta = table.Column<decimal>(type: "decimal(18,2)", precision: 18, scale: 2, nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OptionTiers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionTiers_OptionDefinitions_OptionDefinitionId",
|
||||
column: x => x.OptionDefinitionId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionDefinitions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OptionValues",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
OptionDefinitionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Code = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: false),
|
||||
Label = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: false),
|
||||
PriceDelta = table.Column<decimal>(type: "decimal(9,4)", precision: 9, scale: 4, nullable: true),
|
||||
PriceDeltaKind = table.Column<int>(type: "int", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OptionValues", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionValues_OptionDefinitions_OptionDefinitionId",
|
||||
column: x => x.OptionDefinitionId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionDefinitions",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "OptionRuleConditions",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
RuleSetId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LeftOptionDefinitionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Operator = table.Column<byte>(type: "tinyint", nullable: false),
|
||||
RightOptionValueId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
RightList = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
RightNumber = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
RightMin = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
RightMax = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
|
||||
CreatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
LastModifiedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
LastModifiedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
|
||||
InactivatedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
InactivatedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
DeletedBy = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
DeletedOn = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
|
||||
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_OptionRuleConditions", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionRuleConditions_OptionDefinitions_LeftOptionDefinitionId",
|
||||
column: x => x.LeftOptionDefinitionId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionDefinitions",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionRuleConditions_OptionRuleSets_RuleSetId",
|
||||
column: x => x.RuleSetId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionRuleSets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_OptionRuleConditions_OptionValues_RightOptionValueId",
|
||||
column: x => x.RightOptionValueId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionValues",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "VariantAxisValues",
|
||||
schema: "catalog",
|
||||
columns: table => new
|
||||
{
|
||||
ProductVariantId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
OptionDefinitionId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
OptionValueId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_VariantAxisValues", x => new { x.ProductVariantId, x.OptionDefinitionId });
|
||||
table.ForeignKey(
|
||||
name: "FK_VariantAxisValues_OptionDefinitions_OptionDefinitionId",
|
||||
column: x => x.OptionDefinitionId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionDefinitions",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_VariantAxisValues_OptionValues_OptionValueId",
|
||||
column: x => x.OptionValueId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "OptionValues",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_VariantAxisValues_Products_ProductVariantId",
|
||||
column: x => x.ProductVariantId,
|
||||
principalSchema: "catalog",
|
||||
principalTable: "Products",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AuditLogItems_AuditLogId",
|
||||
table: "AuditLogItems",
|
||||
column: "AuditLogId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Categories_Slug",
|
||||
schema: "catalog",
|
||||
table: "Categories",
|
||||
column: "Slug",
|
||||
unique: true,
|
||||
filter: "[Slug] IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GenericAttributes_Active",
|
||||
table: "GenericAttributes",
|
||||
column: "DeletedOn",
|
||||
filter: "[DeletedOn] IS NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GenericAttributes_Entity_Group",
|
||||
table: "GenericAttributes",
|
||||
columns: new[] { "EntityId", "KeyGroup" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionDefinitions_ProductId_Code",
|
||||
schema: "catalog",
|
||||
table: "OptionDefinitions",
|
||||
columns: new[] { "ProductId", "Code" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionRuleConditions_LeftOptionDefinitionId",
|
||||
schema: "catalog",
|
||||
table: "OptionRuleConditions",
|
||||
column: "LeftOptionDefinitionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionRuleConditions_RightOptionValueId",
|
||||
schema: "catalog",
|
||||
table: "OptionRuleConditions",
|
||||
column: "RightOptionValueId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionRuleConditions_RuleSetId",
|
||||
schema: "catalog",
|
||||
table: "OptionRuleConditions",
|
||||
column: "RuleSetId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionRuleSets_ProductId_TargetKind_TargetId",
|
||||
schema: "catalog",
|
||||
table: "OptionRuleSets",
|
||||
columns: new[] { "ProductId", "TargetKind", "TargetId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionTiers_OptionDefinitionId_FromInclusive_ToInclusive",
|
||||
schema: "catalog",
|
||||
table: "OptionTiers",
|
||||
columns: new[] { "OptionDefinitionId", "FromInclusive", "ToInclusive" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_OptionValues_OptionDefinitionId_Code",
|
||||
schema: "catalog",
|
||||
table: "OptionValues",
|
||||
columns: new[] { "OptionDefinitionId", "Code" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductAttributeValues_AttributeDefinitionId",
|
||||
schema: "catalog",
|
||||
table: "ProductAttributeValues",
|
||||
column: "AttributeDefinitionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductAttributeValues_ProductId_AttributeDefinitionId",
|
||||
schema: "catalog",
|
||||
table: "ProductAttributeValues",
|
||||
columns: new[] { "ProductId", "AttributeDefinitionId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductCategories_CategoryId",
|
||||
schema: "catalog",
|
||||
table: "ProductCategories",
|
||||
column: "CategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_ParentProductId",
|
||||
schema: "catalog",
|
||||
table: "Products",
|
||||
column: "ParentProductId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_Sku",
|
||||
schema: "catalog",
|
||||
table: "Products",
|
||||
column: "Sku",
|
||||
unique: true,
|
||||
filter: "[Sku] IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Products_Slug",
|
||||
schema: "catalog",
|
||||
table: "Products",
|
||||
column: "Slug",
|
||||
unique: true,
|
||||
filter: "[Slug] IS NOT NULL");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VariantAxisValues_OptionDefinitionId",
|
||||
schema: "catalog",
|
||||
table: "VariantAxisValues",
|
||||
column: "OptionDefinitionId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_VariantAxisValues_OptionValueId",
|
||||
schema: "catalog",
|
||||
table: "VariantAxisValues",
|
||||
column: "OptionValueId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "AuditLogItems");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GenericAttributes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OptionRuleConditions",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OptionTiers",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductAttributeValues",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProductCategories",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SeederLogs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "VariantAxisValues",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AuditLogs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OptionRuleSets",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AttributeDefinitions",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Categories",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OptionValues",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "OptionDefinitions",
|
||||
schema: "catalog");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Products",
|
||||
schema: "catalog");
|
||||
}
|
||||
}
|
||||
}
|
||||
1023
Prefab.Web/Data/Migrations/AppDbModelSnapshot.cs
Normal file
1023
Prefab.Web/Data/Migrations/AppDbModelSnapshot.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user