-
This commit is contained in:
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Apollinare.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPurchasesModule : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Suppliers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Code = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
VatNumber = table.Column<string>(type: "TEXT", nullable: true),
|
||||
FiscalCode = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Address = table.Column<string>(type: "TEXT", nullable: true),
|
||||
City = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Province = table.Column<string>(type: "TEXT", nullable: true),
|
||||
ZipCode = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Country = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Email = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Pec = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Phone = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Website = table.Column<string>(type: "TEXT", nullable: true),
|
||||
PaymentTerms = table.Column<string>(type: "TEXT", nullable: true),
|
||||
Notes = table.Column<string>(type: "TEXT", nullable: true),
|
||||
IsActive = table.Column<bool>(type: "INTEGER", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
|
||||
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
|
||||
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Suppliers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchaseOrders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
OrderNumber = table.Column<string>(type: "TEXT", nullable: false),
|
||||
OrderDate = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
ExpectedDeliveryDate = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
SupplierId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Status = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
DestinationWarehouseId = table.Column<int>(type: "INTEGER", nullable: true),
|
||||
Notes = table.Column<string>(type: "TEXT", nullable: true),
|
||||
TotalNet = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
TotalTax = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
TotalGross = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
|
||||
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
|
||||
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchaseOrders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseOrders_Suppliers_SupplierId",
|
||||
column: x => x.SupplierId,
|
||||
principalTable: "Suppliers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseOrders_WarehouseLocations_DestinationWarehouseId",
|
||||
column: x => x.DestinationWarehouseId,
|
||||
principalTable: "WarehouseLocations",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchaseOrderLines",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
PurchaseOrderId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
WarehouseArticleId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Description = table.Column<string>(type: "TEXT", nullable: false),
|
||||
Quantity = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
ReceivedQuantity = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
UnitPrice = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
TaxRate = table.Column<decimal>(type: "TEXT", precision: 18, scale: 2, nullable: false),
|
||||
DiscountPercent = table.Column<decimal>(type: "TEXT", precision: 18, scale: 2, nullable: false),
|
||||
LineTotal = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
CreatedBy = table.Column<string>(type: "TEXT", nullable: true),
|
||||
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
UpdatedBy = table.Column<string>(type: "TEXT", nullable: true),
|
||||
CustomFieldsJson = table.Column<string>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchaseOrderLines", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseOrderLines_PurchaseOrders_PurchaseOrderId",
|
||||
column: x => x.PurchaseOrderId,
|
||||
principalTable: "PurchaseOrders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchaseOrderLines_WarehouseArticles_WarehouseArticleId",
|
||||
column: x => x.WarehouseArticleId,
|
||||
principalTable: "WarehouseArticles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrderLines_PurchaseOrderId",
|
||||
table: "PurchaseOrderLines",
|
||||
column: "PurchaseOrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrderLines_WarehouseArticleId",
|
||||
table: "PurchaseOrderLines",
|
||||
column: "WarehouseArticleId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrders_DestinationWarehouseId",
|
||||
table: "PurchaseOrders",
|
||||
column: "DestinationWarehouseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrders_OrderDate",
|
||||
table: "PurchaseOrders",
|
||||
column: "OrderDate");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrders_OrderNumber",
|
||||
table: "PurchaseOrders",
|
||||
column: "OrderNumber",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrders_Status",
|
||||
table: "PurchaseOrders",
|
||||
column: "Status");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchaseOrders_SupplierId",
|
||||
table: "PurchaseOrders",
|
||||
column: "SupplierId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Suppliers_Code",
|
||||
table: "Suppliers",
|
||||
column: "Code",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Suppliers_IsActive",
|
||||
table: "Suppliers",
|
||||
column: "IsActive");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Suppliers_Name",
|
||||
table: "Suppliers",
|
||||
column: "Name");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Suppliers_VatNumber",
|
||||
table: "Suppliers",
|
||||
column: "VatNumber");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchaseOrderLines");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchaseOrders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Suppliers");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user