using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace foodmarket.Infrastructure.Persistence.Migrations
{
/// Новая модель цен:
/// - products.PurchasePrice → ReferencePrice (справочная цена закупа)
/// - products.+ ReferencePriceUpdatedAt timestamptz NULL
/// - products.+ Cost numeric(18,4) NOT NULL DEFAULT 0 (себестоимость, скользящее среднее)
/// - products.+ LastSupplyAt timestamptz NULL
/// - product_groups.+ MarkupPercent numeric(5,2) NULL (% наценки на cost для авто-розничной)
/// - organizations.+ MultiplePriceTypesEnabled boolean DEFAULT false
/// - organizations.+ ShowReferencePriceOnProduct boolean DEFAULT true
/// - supply_lines.+ RetailPriceManuallyOverridden boolean DEFAULT false
/// - supply_lines.+ RetailPriceOverride numeric(18,2) NULL
///
public partial class Phase3a_PricingModel : Migration
{
protected override void Up(MigrationBuilder b)
{
b.RenameColumn(name: "PurchasePrice", schema: "public", table: "products", newName: "ReferencePrice");
b.AddColumn(
name: "ReferencePriceUpdatedAt", schema: "public", table: "products",
type: "timestamp with time zone", nullable: true);
b.AddColumn(
name: "Cost", schema: "public", table: "products",
type: "numeric(18,4)", precision: 18, scale: 4, nullable: false, defaultValue: 0m);
b.AddColumn(
name: "LastSupplyAt", schema: "public", table: "products",
type: "timestamp with time zone", nullable: true);
b.AddColumn(
name: "MarkupPercent", schema: "public", table: "product_groups",
type: "numeric(5,2)", precision: 5, scale: 2, nullable: true);
b.AddColumn(
name: "MultiplePriceTypesEnabled", schema: "public", table: "organizations",
type: "boolean", nullable: false, defaultValue: false);
b.AddColumn(
name: "ShowReferencePriceOnProduct", schema: "public", table: "organizations",
type: "boolean", nullable: false, defaultValue: true);
b.AddColumn(
name: "RetailPriceManuallyOverridden", schema: "public", table: "supply_lines",
type: "boolean", nullable: false, defaultValue: false);
b.AddColumn(
name: "RetailPriceOverride", schema: "public", table: "supply_lines",
type: "numeric(18,2)", precision: 18, scale: 2, nullable: true);
}
protected override void Down(MigrationBuilder b)
{
b.DropColumn(name: "RetailPriceOverride", schema: "public", table: "supply_lines");
b.DropColumn(name: "RetailPriceManuallyOverridden", schema: "public", table: "supply_lines");
b.DropColumn(name: "ShowReferencePriceOnProduct", schema: "public", table: "organizations");
b.DropColumn(name: "MultiplePriceTypesEnabled", schema: "public", table: "organizations");
b.DropColumn(name: "MarkupPercent", schema: "public", table: "product_groups");
b.DropColumn(name: "LastSupplyAt", schema: "public", table: "products");
b.DropColumn(name: "Cost", schema: "public", table: "products");
b.DropColumn(name: "ReferencePriceUpdatedAt", schema: "public", table: "products");
b.RenameColumn(name: "ReferencePrice", schema: "public", table: "products", newName: "PurchasePrice");
}
}
}