99 lines
4.5 KiB
C#
99 lines
4.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace line_gestao_api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddParcelamentosTables : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ParcelamentoLines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
AnoRef = table.Column<int>(type: "integer", nullable: true),
|
|
Item = table.Column<int>(type: "integer", nullable: true),
|
|
Linha = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
Cliente = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: true),
|
|
QtParcelas = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
ParcelaAtual = table.Column<int>(type: "integer", nullable: true),
|
|
TotalParcelas = table.Column<int>(type: "integer", nullable: true),
|
|
ValorCheio = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
Desconto = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
ValorComDesconto = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ParcelamentoLines", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ParcelamentoMonthValues",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TenantId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ParcelamentoLineId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Competencia = table.Column<DateOnly>(type: "date", nullable: false),
|
|
Valor = table.Column<decimal>(type: "numeric(18,2)", precision: 18, scale: 2, nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ParcelamentoMonthValues", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ParcelamentoMonthValues_ParcelamentoLines_ParcelamentoLineId",
|
|
column: x => x.ParcelamentoLineId,
|
|
principalTable: "ParcelamentoLines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ParcelamentoLines_AnoRef_Item",
|
|
table: "ParcelamentoLines",
|
|
columns: new[] { "AnoRef", "Item" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ParcelamentoLines_Linha",
|
|
table: "ParcelamentoLines",
|
|
column: "Linha");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ParcelamentoLines_TenantId",
|
|
table: "ParcelamentoLines",
|
|
column: "TenantId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ParcelamentoMonthValues_ParcelamentoLineId_Competencia",
|
|
table: "ParcelamentoMonthValues",
|
|
columns: new[] { "ParcelamentoLineId", "Competencia" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ParcelamentoMonthValues_TenantId",
|
|
table: "ParcelamentoMonthValues",
|
|
column: "TenantId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "ParcelamentoMonthValues");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ParcelamentoLines");
|
|
}
|
|
}
|
|
}
|