All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 43s
97 lines
5.9 KiB
C#
97 lines
5.9 KiB
C#
using System;
|
||
using Microsoft.EntityFrameworkCore.Migrations;
|
||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||
|
||
#nullable disable
|
||
|
||
namespace TakeoutSaaS.Infrastructure.Migrations
|
||
{
|
||
/// <inheritdoc />
|
||
public partial class AddProductLabels : Migration
|
||
{
|
||
/// <inheritdoc />
|
||
protected override void Up(MigrationBuilder migrationBuilder)
|
||
{
|
||
migrationBuilder.CreateTable(
|
||
name: "product_label_products",
|
||
columns: table => new
|
||
{
|
||
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
|
||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||
StoreId = table.Column<long>(type: "bigint", nullable: false, comment: "所属门店。"),
|
||
LabelId = table.Column<long>(type: "bigint", nullable: false, comment: "标签 ID。"),
|
||
ProductId = table.Column<long>(type: "bigint", nullable: false, comment: "商品 ID。"),
|
||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间(UTC)。"),
|
||
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间(UTC),从未更新时为 null。"),
|
||
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间(UTC),未删除时为 null。"),
|
||
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
|
||
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
|
||
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
|
||
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_product_label_products", x => x.Id);
|
||
},
|
||
comment: "标签与商品关联关系。");
|
||
|
||
migrationBuilder.CreateTable(
|
||
name: "product_labels",
|
||
columns: table => new
|
||
{
|
||
Id = table.Column<long>(type: "bigint", nullable: false, comment: "实体唯一标识。")
|
||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||
StoreId = table.Column<long>(type: "bigint", nullable: false, comment: "所属门店。"),
|
||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false, comment: "标签名称。"),
|
||
Color = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false, comment: "标签颜色(HEX)。"),
|
||
SortOrder = table.Column<int>(type: "integer", nullable: false, comment: "排序值。"),
|
||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false, comment: "是否启用。"),
|
||
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "创建时间(UTC)。"),
|
||
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "最近一次更新时间(UTC),从未更新时为 null。"),
|
||
DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "软删除时间(UTC),未删除时为 null。"),
|
||
CreatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "创建人用户标识,匿名或系统操作时为 null。"),
|
||
UpdatedBy = table.Column<long>(type: "bigint", nullable: true, comment: "最后更新人用户标识,匿名或系统操作时为 null。"),
|
||
DeletedBy = table.Column<long>(type: "bigint", nullable: true, comment: "删除人用户标识(软删除),未删除时为 null。"),
|
||
TenantId = table.Column<long>(type: "bigint", nullable: false, comment: "所属租户 ID。")
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_product_labels", x => x.Id);
|
||
},
|
||
comment: "商品标签模板(门店维度)。");
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_product_label_products_TenantId_StoreId_LabelId_ProductId",
|
||
table: "product_label_products",
|
||
columns: new[] { "TenantId", "StoreId", "LabelId", "ProductId" },
|
||
unique: true);
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_product_label_products_TenantId_StoreId_ProductId",
|
||
table: "product_label_products",
|
||
columns: new[] { "TenantId", "StoreId", "ProductId" });
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_product_labels_TenantId_StoreId_IsEnabled_SortOrder",
|
||
table: "product_labels",
|
||
columns: new[] { "TenantId", "StoreId", "IsEnabled", "SortOrder" });
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_product_labels_TenantId_StoreId_Name",
|
||
table: "product_labels",
|
||
columns: new[] { "TenantId", "StoreId", "Name" },
|
||
unique: true);
|
||
}
|
||
|
||
/// <inheritdoc />
|
||
protected override void Down(MigrationBuilder migrationBuilder)
|
||
{
|
||
migrationBuilder.DropTable(
|
||
name: "product_label_products");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "product_labels");
|
||
}
|
||
}
|
||
}
|