using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PowderCoating.Infrastructure.Migrations
{
///
public partial class AddDeposits : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Deposits",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ReceiptNumber = table.Column(type: "nvarchar(max)", nullable: false),
CustomerId = table.Column(type: "int", nullable: false),
JobId = table.Column(type: "int", nullable: true),
QuoteId = table.Column(type: "int", nullable: true),
Amount = table.Column(type: "decimal(18,2)", nullable: false),
PaymentMethod = table.Column(type: "int", nullable: false),
ReceivedDate = table.Column(type: "datetime2", nullable: false),
Reference = table.Column(type: "nvarchar(max)", nullable: true),
Notes = table.Column(type: "nvarchar(max)", nullable: true),
RecordedById = table.Column(type: "nvarchar(450)", nullable: true),
AppliedToInvoiceId = table.Column(type: "int", nullable: true),
AppliedDate = table.Column(type: "datetime2", nullable: true),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Deposits", x => x.Id);
table.ForeignKey(
name: "FK_Deposits_AspNetUsers_RecordedById",
column: x => x.RecordedById,
principalTable: "AspNetUsers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Deposits_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Deposits_Invoices_AppliedToInvoiceId",
column: x => x.AppliedToInvoiceId,
principalTable: "Invoices",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_Deposits_Jobs_JobId",
column: x => x.JobId,
principalTable: "Jobs",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Deposits_Quotes_QuoteId",
column: x => x.QuoteId,
principalTable: "Quotes",
principalColumn: "Id");
});
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 3, 29, 0, 58, 35, 757, DateTimeKind.Utc).AddTicks(6949));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 3, 29, 0, 58, 35, 757, DateTimeKind.Utc).AddTicks(6955));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 3, 29, 0, 58, 35, 757, DateTimeKind.Utc).AddTicks(6957));
migrationBuilder.CreateIndex(
name: "IX_Deposits_AppliedToInvoiceId",
table: "Deposits",
column: "AppliedToInvoiceId");
migrationBuilder.CreateIndex(
name: "IX_Deposits_CustomerId",
table: "Deposits",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_Deposits_JobId",
table: "Deposits",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_Deposits_QuoteId",
table: "Deposits",
column: "QuoteId");
migrationBuilder.CreateIndex(
name: "IX_Deposits_RecordedById",
table: "Deposits",
column: "RecordedById");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Deposits");
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 1,
column: "CreatedAt",
value: new DateTime(2026, 3, 29, 0, 32, 56, 736, DateTimeKind.Utc).AddTicks(8710));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 2,
column: "CreatedAt",
value: new DateTime(2026, 3, 29, 0, 32, 56, 736, DateTimeKind.Utc).AddTicks(8717));
migrationBuilder.UpdateData(
table: "PricingTiers",
keyColumn: "Id",
keyValue: 3,
column: "CreatedAt",
value: new DateTime(2026, 3, 29, 0, 32, 56, 736, DateTimeKind.Utc).AddTicks(8718));
}
}
}