85 lines
3.6 KiB
C#
85 lines
3.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace SIFinance.Shared.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddBudgetsService : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "budgets_service",
|
|
schema: "achats",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
service_id = table.Column<int>(type: "int", nullable: false),
|
|
exercice_annee = table.Column<int>(type: "int", nullable: false),
|
|
montant_initial = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
|
montant_revise = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
|
|
date_revision = table.Column<DateTime>(type: "datetime", nullable: true),
|
|
revise_par = table.Column<int>(type: "int", nullable: true),
|
|
commentaire_revision = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: true),
|
|
saisie_par_id = table.Column<int>(type: "int", nullable: false),
|
|
date_creation = table.Column<DateTime>(type: "datetime", nullable: true, defaultValueSql: "(getdate())"),
|
|
date_derniere_maj = table.Column<DateTime>(type: "datetime", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_budgets_service", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_budgets_service_revise_par",
|
|
column: x => x.revise_par,
|
|
principalSchema: "core",
|
|
principalTable: "utilisateurs",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
table.ForeignKey(
|
|
name: "FK_budgets_service_saisie_par",
|
|
column: x => x.saisie_par_id,
|
|
principalSchema: "core",
|
|
principalTable: "utilisateurs",
|
|
principalColumn: "id");
|
|
table.ForeignKey(
|
|
name: "FK_budgets_service_service",
|
|
column: x => x.service_id,
|
|
principalSchema: "ref",
|
|
principalTable: "services",
|
|
principalColumn: "id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_budgets_service_revise_par",
|
|
schema: "achats",
|
|
table: "budgets_service",
|
|
column: "revise_par");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_budgets_service_saisie_par_id",
|
|
schema: "achats",
|
|
table: "budgets_service",
|
|
column: "saisie_par_id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_budgets_service_unique",
|
|
schema: "achats",
|
|
table: "budgets_service",
|
|
columns: new[] { "service_id", "exercice_annee" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "budgets_service",
|
|
schema: "achats");
|
|
}
|
|
}
|
|
}
|